[FIX] account: prevent loops when unreconciling entries
7544c22de9 refactored the handling of
exchange rate entries when unreconciling entries.
However it did not preserve the piece of code that prevented loops
during this operation (`full_rec_lookup` context key).
This could cause the unreconciliation of entries with an exchange rate
difference to fail with a confusing error claiming that the user is
trying "to reconcile some entries that are already reconciled!".
The double reconciliation was caused by a recursive attempt to reverse
the exchange rate entry.
This commit is contained in:
@@ -1679,6 +1679,9 @@ class AccountFullReconcile(models.Model):
|
||||
"""
|
||||
for rec in self:
|
||||
if rec.exchange_move_id:
|
||||
#reverse the exchange rate entry
|
||||
rec.exchange_move_id.reverse_moves()
|
||||
# reverse the exchange rate entry after de-referencing it to avoid looping
|
||||
# (reversing will cause a nested attempt to drop the full reconciliation)
|
||||
to_reverse = rec.exchange_move_id
|
||||
rec.exchange_move_id = False
|
||||
to_reverse.reverse_moves()
|
||||
return super(AccountFullReconcile, self).unlink()
|
||||
|
||||
Reference in New Issue
Block a user