This commit is contained in:
2026-03-16 14:46:11 +01:00
parent 498da9a728
commit e78eb80d08

View File

@@ -72,7 +72,7 @@ class Fee(ModelSQL,ModelView):
states={
'readonly': (Bool(Eval('mode') != 'ppack') & Bool(Eval('mode') != 'perqt')),
})
packing_category = fields.Function(fields.Many2One('product.uom.category',"Packing Category"),'get_packing_category')
packing_category = fields.Function(fields.Many2One('product.uom.category',"Packing Category"),'on_change_with_packing_category')
inherit_shipment = fields.Boolean("Inh Sh",states={
'invisible': (Eval('shipment_in')),
})
@@ -110,7 +110,7 @@ class Fee(ModelSQL,ModelView):
if lqt:
return lqt[0].id
def get_packing_category(self, name):
def on_change_with_packing_category(self, name=None):
UnitCategory = Pool().get('product.uom.category')
packing = UnitCategory.search(['name','=','Packing'])
if packing:
@@ -151,26 +151,26 @@ class Fee(ModelSQL,ModelView):
if self.auto_calculation:
return (qt * Decimal(unit.factor) / Decimal(self.unit.factor)).to_integral_value(rounding=ROUND_UP)
# @fields.depends('price','mode','_parent_line.lots','_parent_sale_line.lots','shipment_in')
# def on_change_with_unit(self, name=None):
# if self.mode != 'ppack' and self.mode != 'perqt':
# line = self.line
# if not line:
# line = self.sale_line
# if line:
# if line.lots:
# if len(line.lots) == 1:
# return line.lots[0].lot_unit_line
# else:
# return line.lots[1].lot_unit_line
# if self.shipment_in:
# Lot = Pool().get('lot.lot')
# lots = Lot.search([('lot_shipment_in','=',self.shipment_in.id)])
# logger.info("ON_CHANGE_WITH_UNIT:%s",lots)
# if lots:
# return lots[0].lot_unit_line
# else:
# return self.unit
@fields.depends('price','mode','_parent_line.lots','_parent_sale_line.lots','shipment_in')
def on_change_with_unit(self, name=None):
if self.mode != 'ppack' and self.mode != 'perqt':
line = self.line
if not line:
line = self.sale_line
if line:
if line.lots:
if len(line.lots) == 1:
return line.lots[0].lot_unit_line
else:
return line.lots[1].lot_unit_line
if self.shipment_in:
Lot = Pool().get('lot.lot')
lots = Lot.search([('lot_shipment_in','=',self.shipment_in.id)])
logger.info("ON_CHANGE_WITH_UNIT:%s",lots)
if lots:
return lots[0].lot_unit_line
else:
return self.unit
def get_lots(self, name):
logger.info("GET_LOTS_LINE:%s",self.line)