[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:
Olivier Dony
2017-03-06 16:17:10 +01:00
parent ee5241a2f3
commit 4f40c9da7b
+5 -2
View File
@@ -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()