From 2242a08f85143d1954787fa9235da1e35bb7b7bf Mon Sep 17 00:00:00 2001 From: Jorge Pinna Puissant Date: Tue, 17 Mar 2020 13:47:48 +0000 Subject: [PATCH] [FIX] account: date of currency exchange reversal - Create and validate an invoice in a date (near the end of the fiscal year for example: 20.12.2019) in a foreign currency; - Pays the invoice in a different date (23.12.2019), the invoice is settled and a currency exchange is created; - In the new fiscal year (for example: 03.01.2020), amends the invoice (a description change for instance): cancel the invoice, change the invoice into draft, made the amends, re-validate the invoice and re-settle the invoice (a new currency exchange reversal is created). Before this commit, when cancelling the invoice, a currency exchange reversal is created at the current date (03.01.2020) to revert the first currency exchange reversal. When the invoice is re-settle, a new currency exchange is created a date of the payment (23.12.2019). This means that, in the fiscal year of 2019 two currency exchanges were created, and in the new fiscal year of 2020 a currency exchange revert is created. To avoid this erroneous situation, the date of a currency exchange reversal should be the creation date of the currency exchange. Now the currency exchange reversal entries has the same date as the initial currency exchange entry. opw-2209675 closes odoo/odoo#48344 X-original-commit: cedfbd0379a907650db9b23f6c5203522d4ced95 Signed-off-by: Jorge Pinna Puissant (jpp) --- addons/account/models/account_move.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/addons/account/models/account_move.py b/addons/account/models/account_move.py index c1dd1901c81..ffa5010d415 100644 --- a/addons/account/models/account_move.py +++ b/addons/account/models/account_move.py @@ -4507,8 +4507,12 @@ class AccountFullReconcile(models.Model): # (reversing will cause a nested attempt to drop the full reconciliation) to_reverse = rec.exchange_move_id rec.exchange_move_id = False + if to_reverse.date > (to_reverse.company_id.period_lock_date or date.min): + reverse_date = to_reverse.date + else: + reverse_date = fields.Date.today() to_reverse._reverse_moves([{ - 'date': fields.Date.today(), + 'date': reverse_date, 'ref': _('Reversal of: %s') % to_reverse.name, }], cancel=True) return super(AccountFullReconcile, self).unlink()