main #7

Merged
admin merged 620 commits from main into dev 2026-03-29 13:03:25 +00:00
Showing only changes of commit 6d053dfe03 - Show all commits

View File

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