fix: force account move synchronization by including amount in trigger fields when deductions change

This commit is contained in:
Suherdy Yacob 2026-04-06 11:47:47 +07:00
parent e659fe5edf
commit ce614c273d

View File

@ -43,11 +43,13 @@ class AccountPayment(models.Model):
def write(self, vals):
"""
Override write to manually trigger synchronization when deductions change.
We include 'amount' in the changed_fields to trick Odoo's core sync engine
into refreshing the move lines, which will then include the deductions.
"""
res = super().write(vals)
if 'deduction_line_ids' in vals or 'amount_substract' in vals:
# If deductions change, trigger sync to moves
self._synchronize_to_moves({'deduction_line_ids', 'amount_substract'})
# Force trigger sync by pretending amount changed if deductions changed
self._synchronize_to_moves({'amount', 'deduction_line_ids', 'amount_substract'})
return res
def action_cancel(self):