account_custom_internal_tra.../models/account_move.py

19 lines
799 B
Python

from odoo import models, api
class AccountMove(models.Model):
_inherit = 'account.move'
def set_moves_checked(self, is_checked=True):
""" Hook into the 'Review' action of the bank reconciliation widget.
When a move is marked as checked, if it's linked to an internal transfer,
trigger the automation of the destination leg.
"""
res = super().set_moves_checked(is_checked=is_checked)
if is_checked:
for move in self:
# In Odoo 19, statement lines are moves or linked to moves via statement_line_id
st_line = move.statement_line_id
if st_line and st_line.bank_internal_transfer_id:
st_line.bank_internal_transfer_id._automate_destination_leg()
return res