From 9c6029d15207e17e5dd84ad165b87cb15578d1f5 Mon Sep 17 00:00:00 2001 From: laurentbarontini Date: Sat, 17 Jan 2026 09:25:00 +0100 Subject: [PATCH] 17.01.26 --- modules/purchase_trade/fee.py | 16 +++++++++++++++- modules/purchase_trade/lot.py | 8 ++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/modules/purchase_trade/fee.py b/modules/purchase_trade/fee.py index 62fd50e..2eb09c8 100755 --- a/modules/purchase_trade/fee.py +++ b/modules/purchase_trade/fee.py @@ -367,7 +367,21 @@ class Fee(ModelSQL,ModelView): p.currency = record.currency p.line_type = 'service' Purchase.save([p]) - + #if reception of moves done we need to generate accrual for fee + StockMove = Pool().get('stock.move') + feelots = FeeLots.search(['fee','=',record.id]) + for lot in feelots: + move = lot.get_received_move() + if move: + Warning = Pool().get('res.user.warning') + warning_name = Warning.format("Lot ever received", []) + if Warning.check(warning_name): + raise Warning(warning_name, + "By clicking yes, an accrual for this fee will be created") + AccountMove = Pool().get('account.move') + account_move = move._get_account_stock_move_fee(record.id) + AccountMove.save([account_move]) + return records class FeeLots(ModelSQL,ModelView): diff --git a/modules/purchase_trade/lot.py b/modules/purchase_trade/lot.py index 5995b6c..ee7bac2 100755 --- a/modules/purchase_trade/lot.py +++ b/modules/purchase_trade/lot.py @@ -578,6 +578,14 @@ class Lot(metaclass=PoolMeta): return True return False + def get_received_move(self): + if self.lot_move: + lm = sorted(self.lot_move, key=lambda x: x.sequence, reverse=True) + for m in lm: + if m.move.from_location.type == 'supplier' and m.move.state == 'done': + return m + return None + def GetShipment(self,type): if type == 'in': m = self.get_current_supplier_move() -- 2.49.1