05.02.26
This commit is contained in:
@@ -6,7 +6,7 @@ from trytond.pyson import Bool, Eval, Id, If
|
||||
from trytond.model import (ModelSQL, ModelView)
|
||||
from trytond.tools import is_full_text, lstrip_wildcard
|
||||
from trytond.transaction import Transaction, inactive_records
|
||||
from decimal import getcontext, Decimal, ROUND_HALF_UP
|
||||
from decimal import getcontext, Decimal, ROUND_UP, ROUND_HALF_UP
|
||||
from sql.aggregate import Count, Max, Min, Sum, Avg, BoolOr
|
||||
from sql.conditionals import Case
|
||||
from sql import Column, Literal
|
||||
@@ -103,12 +103,14 @@ class Fee(ModelSQL,ModelView):
|
||||
@fields.depends('unit','auto_calculation','mode','_parent_line.unit','_parent_line.lots','_parent_sale_line.unit','_parent_sale_line.lots','_parent_shipment_in.id')
|
||||
def on_change_with_quantity(self, name=None):
|
||||
qt = None
|
||||
unit = None
|
||||
line = self.line
|
||||
if not line:
|
||||
line = self.sale_line
|
||||
if line:
|
||||
if line.lots:
|
||||
qt = sum([e.get_current_quantity() for e in line.lots])
|
||||
unit = line.lots[0].lot_unit_line
|
||||
logger.info("ON_CHANGE_WITH_QT0:%s",qt)
|
||||
if not qt:
|
||||
logger.info("ON_CHANGE_WITH_QT1:%s",qt)
|
||||
@@ -116,12 +118,13 @@ class Fee(ModelSQL,ModelView):
|
||||
lqts = LotQt.search(['lot_shipment_in','=',self.shipment_in.id])
|
||||
if lqts:
|
||||
qt = Decimal(lqts[0].lot_quantity)
|
||||
unit = lqts[0].lot_unit
|
||||
logger.info("ON_CHANGE_WITH_QT2:%s",qt)
|
||||
if self.mode != 'ppack':
|
||||
return qt
|
||||
else:
|
||||
if self.auto_calculation:
|
||||
return Decimal(int(qt/Decimal(self.unit.factor)))
|
||||
return (qt * unit.factor / Decimal(self.unit.factor)).to_integral_value(rounding=ROUND_UP)
|
||||
|
||||
@fields.depends('mode','_parent_line.lots','_parent_sale_line.lots')
|
||||
def on_change_with_unit(self, name=None):
|
||||
|
||||
Reference in New Issue
Block a user