This commit is contained in:
2026-03-10 15:01:09 +01:00
parent 814071e4c1
commit c0cffde079

View File

@@ -355,16 +355,16 @@ class Fee(ModelSQL,ModelView):
return round(factor * self.sale_line.unit_price * (self.quantity if self.quantity else 0) * sign,2)
elif self.mode == 'perqt':
# if self.shipment_in:
# StockMove = Pool().get('stock.move')
# 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)
# LotQt = Pool().get('lot.qt')
# lqts = LotQt.search(['lot_shipment_in','=',self.shipment_in.id])
# if lqts:
# return round(self.price * Decimal(lqts[0].lot_quantity) * sign,2)
if self.shipment_in:
StockMove = Pool().get('stock.move')
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)
LotQt = Pool().get('lot.qt')
lqts = LotQt.search(['lot_shipment_in','=',self.shipment_in.id])
if lqts:
return round(self.price * Decimal(lqts[0].lot_quantity) * sign,2)
return round((self.quantity if self.quantity else 0) * self.price * sign,2)
elif self.mode == 'pprice':
@@ -454,45 +454,45 @@ class Fee(ModelSQL,ModelView):
FeeLots = Pool().get('fee.lots')
Lots = Pool().get('lot.lot')
LotQt = Pool().get('lot.qt')
# if fee.line:
# for l in fee.line.lots:
# if (l.lot_type == 'virtual' and len(fee.line.lots)==1) or (l.lot_type == 'physic' and len(fee.line.lots)>1):
# fl = FeeLots()
# fl.fee = fee.id
# fl.lot = l.id
# fl.line = l.line.id
# FeeLots.save([fl])
# qt_line += l.get_current_quantity_converted()
# unit = l.line.unit
# if fee.sale_line:
# for l in fee.sale_line.lots:
# if (l.lot_type == 'virtual' and len(fee.sale_line.lots)==1) or (l.lot_type == 'physic' and len(fee.sale_line.lots)>1):
# fl = FeeLots()
# fl.fee = fee.id
# fl.lot = l.id
# fl.sale_line = l.sale_line.id
# FeeLots.save([fl])
# qt_line += l.get_current_quantity_converted()
# unit = l.sale_line.unit
# if fee.shipment_in:
# if fee.shipment_in.state == 'draft'or fee.shipment_in.state == 'started':
# lots = Lots.search(['lot_shipment_in','=',fee.shipment_in.id])
# if lots:
# for l in lots:
# fl = FeeLots()
# fl.fee = fee.id
# fl.lot = l.id
# FeeLots.save([fl])
# qt_sh += l.get_current_quantity_converted()
# unit = l.line.unit
# else:
# lqts = LotQt.search(['lot_shipment_in','=',fee.shipment_in.id])
# if lqts:
# for l in lqts:
# qt_sh += l.lot_p.get_current_quantity_converted()
# unit = l.lot_p.line.unit
# else:
# raise UserError("You cannot add fee on received shipment!")
if fee.line:
for l in fee.line.lots:
if (l.lot_type == 'virtual' and len(fee.line.lots)==1) or (l.lot_type == 'physic' and len(fee.line.lots)>1):
fl = FeeLots()
fl.fee = fee.id
fl.lot = l.id
fl.line = l.line.id
FeeLots.save([fl])
qt_line += l.get_current_quantity_converted()
unit = l.line.unit
if fee.sale_line:
for l in fee.sale_line.lots:
if (l.lot_type == 'virtual' and len(fee.sale_line.lots)==1) or (l.lot_type == 'physic' and len(fee.sale_line.lots)>1):
fl = FeeLots()
fl.fee = fee.id
fl.lot = l.id
fl.sale_line = l.sale_line.id
FeeLots.save([fl])
qt_line += l.get_current_quantity_converted()
unit = l.sale_line.unit
if fee.shipment_in:
if fee.shipment_in.state == 'draft'or fee.shipment_in.state == 'started':
lots = Lots.search(['lot_shipment_in','=',fee.shipment_in.id])
if lots:
for l in lots:
fl = FeeLots()
fl.fee = fee.id
fl.lot = l.id
FeeLots.save([fl])
qt_sh += l.get_current_quantity_converted()
unit = l.line.unit
else:
lqts = LotQt.search(['lot_shipment_in','=',fee.shipment_in.id])
if lqts:
for l in lqts:
qt_sh += l.lot_p.get_current_quantity_converted()
unit = l.lot_p.line.unit
else:
raise UserError("You cannot add fee on received shipment!")
type = fee.type
if type == 'ordered':