From 4f40c9da7b26dab9b6eb64aa5df2fe408fa3b24c Mon Sep 17 00:00:00 2001 From: Olivier Dony Date: Mon, 6 Mar 2017 15:22:34 +0100 Subject: [PATCH] [FIX] account: prevent loops when unreconciling entries 7544c22de9a4cea028ff8fe63931bf68573e0821 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. --- addons/account/models/account_move.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/addons/account/models/account_move.py b/addons/account/models/account_move.py index 1252aa647bf..b3b536a3483 100644 --- a/addons/account/models/account_move.py +++ b/addons/account/models/account_move.py @@ -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()