This commit is contained in:
2026-03-13 14:47:13 +01:00
parent cc5f4da38c
commit b20b0c8df6
2 changed files with 8 additions and 6 deletions

View File

@@ -510,15 +510,17 @@ class Lot(ModelSQL, ModelView):
# else:
# return self.get_virtual_diff()
def get_current_quantity_converted(self,state_id=0,name=None):
def get_current_quantity_converted(self,state_id=0,unit=None):
Uom = Pool().get('product.uom')
unit = self.line.unit if self.line else self.sale_line.unit
if not unit:
unit = self.line.unit if self.line else self.sale_line.unit
qt, gross_qt = self.get_hist_quantity(state_id)
return round(Decimal(Uom.compute_qty(self.lot_unit_line, float(qt), unit)),5)
def get_current_gross_quantity_converted(self,state_id=0,name=None):
def get_current_gross_quantity_converted(self,state_id=0,unit=None):
Uom = Pool().get('product.uom')
unit = self.line.unit if self.line else self.sale_line.unit
if not unit:
unit = self.line.unit if self.line else self.sale_line.unit
qt, gross_qt = self.get_hist_quantity(state_id)
return round(Decimal(Uom.compute_qty(self.lot_unit_line, float(gross_qt), unit)),5)

View File

@@ -367,7 +367,7 @@ class Fee(ModelSQL,ModelView):
sm = StockMove.search(['shipment','=','stock.shipment.in,'+str(self.shipment_in.id)])
if sm:
unique_lots = {e.lot for e in sm if e.lot}
return round(self.price * Decimal(sum([e.get_current_quantity_converted() for e in unique_lots])) * sign,2)
return round(self.price * Decimal(sum([e.get_current_quantity_converted(0,self.unit) for e in unique_lots])) * sign,2)
LotQt = Pool().get('lot.qt')
lqts = LotQt.search(['lot_shipment_in','=',self.shipment_in.id])
if lqts:
@@ -415,7 +415,7 @@ class Fee(ModelSQL,ModelView):
FeeLots = Pool().get('fee.lots')
fee_lots = FeeLots.search([('fee', '=', self.id)])
if fee_lots:
qt = sum([e.lot.get_current_quantity_converted(state_id) for e in fee_lots])
qt = sum([e.lot.get_current_quantity_converted(state_id,self.unit) for e in fee_lots])
logger.info("GET_FEE_LOTS_QT:%s",qt)
return qt