This commit is contained in:
2026-01-17 09:25:00 +01:00
parent 660e714983
commit 9c6029d152
2 changed files with 23 additions and 1 deletions

View File

@@ -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):

View File

@@ -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()