[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
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user