From e9a62bcd8f1d87ebca3b60a5cf1dd91e27e16893 Mon Sep 17 00:00:00 2001 From: Laurent Smet Date: Tue, 2 Feb 2021 14:14:46 +0000 Subject: [PATCH] [FIX] account: Fix computed fields when editing payment account When changing the bank account by the outstanding account of a payment, invoice's payment_state should be recomputed by the orm. So, when writing 'account_id' on the liquidity line, 'is_matched' must be recomputed on payment (_compute_reconciliation_status). Then, if reconciled to some invoices, 'payment_state' must be recomputed as well (_compute_amount). closes odoo/odoo#65427 X-original-commit: 7caf5316407ab8950216592e38551f29207076de Signed-off-by: oco-odoo Signed-off-by: Laurent Smet --- addons/account/models/account_move.py | 2 ++ addons/account/models/account_payment.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/addons/account/models/account_move.py b/addons/account/models/account_move.py index 4cf8a01a95b..6f952b94a35 100644 --- a/addons/account/models/account_move.py +++ b/addons/account/models/account_move.py @@ -1215,8 +1215,10 @@ class AccountMove(models.Model): return 'paid' @api.depends( + 'line_ids.matched_debit_ids.debit_move_id.move_id.payment_id.is_matched', 'line_ids.matched_debit_ids.debit_move_id.move_id.line_ids.amount_residual', 'line_ids.matched_debit_ids.debit_move_id.move_id.line_ids.amount_residual_currency', + 'line_ids.matched_credit_ids.credit_move_id.move_id.payment_id.is_matched', 'line_ids.matched_credit_ids.credit_move_id.move_id.line_ids.amount_residual', 'line_ids.matched_credit_ids.credit_move_id.move_id.line_ids.amount_residual_currency', 'line_ids.debit', diff --git a/addons/account/models/account_payment.py b/addons/account/models/account_payment.py index 4adabbc1145..992b0d322ee 100644 --- a/addons/account/models/account_payment.py +++ b/addons/account/models/account_payment.py @@ -272,7 +272,7 @@ class AccountPayment(models.Model): # COMPUTE METHODS # ------------------------------------------------------------------------- - @api.depends('move_id.line_ids.amount_residual', 'move_id.line_ids.amount_residual_currency') + @api.depends('move_id.line_ids.amount_residual', 'move_id.line_ids.amount_residual_currency', 'move_id.line_ids.account_id') def _compute_reconciliation_status(self): ''' Compute the field indicating if the payments are already reconciled with something. This field is used for display purpose (e.g. display the 'reconcile' button redirecting to the reconciliation