From f07e0c1af2091cc8f1d1c035a962c974e561e852 Mon Sep 17 00:00:00 2001 From: Denis Ledoux Date: Thu, 3 Dec 2015 10:46:54 +0100 Subject: [PATCH] [FIX] account: force `amount_residual` recomputation on post The `amount_residual` computation depends on the fact the `acccount_id` of the move line does allow reconciliation or not. If it doesn't, the amount residual will always be 0.0. So, if you check the "allow reconciliation" on the account after creating the journal items or after changing the debit/credit amount, the amount residual is not recomputed. We do not set the `depends` directly on `account_id.reconcile`, as, if we do, and a user checks/unchecks this box on an account having a lot of records, this will recompute this residual amount on all lines, and this is something we do not want to happen. The work-around when this case happens, that the amount residual is not correct due to the fact the `allow reconciliation` on the account was checked after having posted the entry, is to cancel the entry and repost it. This will recompute the residual amount. opw-656972 --- addons/account/models/account_move.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/account/models/account_move.py b/addons/account/models/account_move.py index 574115a8ef0..3de5fd8bfed 100644 --- a/addons/account/models/account_move.py +++ b/addons/account/models/account_move.py @@ -219,7 +219,7 @@ class AccountMoveLine(models.Model): _description = "Journal Item" _order = "date desc, id desc" - @api.depends('debit', 'credit', 'amount_currency', 'currency_id', 'matched_debit_ids.amount', 'matched_credit_ids.amount', 'account_id.currency_id') + @api.depends('debit', 'credit', 'amount_currency', 'currency_id', 'matched_debit_ids.amount', 'matched_credit_ids.amount', 'account_id.currency_id', 'move_id.state') def _amount_residual(self): """ Computes the residual amount of a move line from a reconciliable account in the company currency and the line's currency. This amount will be 0 for fully reconciled lines or lines from a non-reconciliable account, the original line amount