From 1c3d1eed015b2fc19245657ae861a3cb6831bde8 Mon Sep 17 00:00:00 2001 From: Jorge Pinna Puissant Date: Mon, 30 Mar 2020 10:03:03 +0000 Subject: [PATCH] [FIX] account: avoid convert amount in currency into debit/credit in a reverse entry - Create an account in foreign currency; - Create different currency rates for the foreign currency at different dates; - Create a journal entry at past date X with 2 lines, and use the "foreign currency account" for one of the lines, but a domestic currency account for the other; - Now try to reverse the entry at a later date with a different exchange rate (select an appropriate date in the wizard). Before this commit, an error was raise because the move is not balanced. This issue occurs because the 'amount_currency' value is used to recompute the debit/credit value based on original currency rate. But the _onchange_currency function is also called, and it recomputes the credit/debit for the foreign currency line with the exchange rate of the date of the reverse entry. This commit is a fine-tuning of ae3d7aeb706dc1bc3216fd63c6a943e5d9cb56e7 to avoid recomputing credit/debit in a reverse entry. opw-2227098 closes odoo/odoo#48609 X-original-commit: 748b2bcb3950840d815040684f72802c968240f2 Signed-off-by: Simon Goffin (sig) Signed-off-by: Jorge Pinna Puissant (jpp) --- 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 f6aa47d517f..a42c7d39928 100644 --- a/addons/account/models/account_move.py +++ b/addons/account/models/account_move.py @@ -3054,7 +3054,7 @@ class AccountMoveLine(models.Model): for line in self: if line.move_id.is_invoice(include_receipts=True): line._onchange_price_subtotal() - else: + elif not line.move_id.reversed_entry_id: line._recompute_debit_credit_from_amount_currency() def _recompute_debit_credit_from_amount_currency(self):