[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) <sig@openerp.com>
Signed-off-by: Jorge Pinna Puissant (jpp) <jpp@odoo.com>
This commit is contained in:
Jorge Pinna Puissant
2020-03-30 12:33:13 +00:00
parent 91d341adce
commit 1c3d1eed01
+1 -1
View File
@@ -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):