[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) <jpp@odoo.com>
This commit is contained in:
Jorge Pinna Puissant
2020-03-25 12:13:46 +00:00
parent 2ddb3a23b8
commit 2242a08f85
+5 -1
View File
@@ -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()