This commit is contained in:
2026-03-10 12:59:07 +01:00
parent 5f49e01495
commit 6d053dfe03

View File

@@ -109,40 +109,40 @@ class Fee(ModelSQL,ModelView):
if lqt:
return lqt[0].id
@fields.depends('price','unit','auto_calculation','mode','_parent_line.unit','_parent_line.lots','_parent_sale_line.unit','_parent_sale_line.lots','_parent_shipment_in')
def on_change_with_quantity(self, name=None):
qt = None
unit = None
line = self.line
logger.info("ON_CHANGE_WITH_LINE:%s",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 self.shipment_in:
Lot = Pool().get('lot.lot')
lots = Lot.search([('lot_shipment_in','=',self.shipment_in.id)])
logger.info("ON_CHANGE_WITH_LOTS:%s",lots)
if lots:
qt = sum([e.get_current_quantity() for e in lots])
unit = lots[0].lot_unit_line
if not qt:
logger.info("ON_CHANGE_WITH_QT1:%s",qt)
LotQt = Pool().get('lot.qt')
if self.shipment_in:
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 (qt * Decimal(unit.factor) / Decimal(self.unit.factor)).to_integral_value(rounding=ROUND_UP)
# @fields.depends('price','unit','auto_calculation','mode','_parent_line.unit','_parent_line.lots','_parent_sale_line.unit','_parent_sale_line.lots','_parent_shipment_in')
# def on_change_with_quantity(self, name=None):
# qt = None
# unit = None
# line = self.line
# logger.info("ON_CHANGE_WITH_LINE:%s",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 self.shipment_in:
# Lot = Pool().get('lot.lot')
# lots = Lot.search([('lot_shipment_in','=',self.shipment_in.id)])
# logger.info("ON_CHANGE_WITH_LOTS:%s",lots)
# if lots:
# qt = sum([e.get_current_quantity() for e in lots])
# unit = lots[0].lot_unit_line
# if not qt:
# logger.info("ON_CHANGE_WITH_QT1:%s",qt)
# LotQt = Pool().get('lot.qt')
# if self.shipment_in:
# 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 (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')
def on_change_with_unit(self, name=None):