From 46bb7921e79c4a15fbfbc0dfef72be34d9ce5537 Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Thu, 18 May 2017 16:04:38 +0200 Subject: [PATCH] [FIX] account: avoid with_context in loop Because it uses a different cache for each iteration, which slows down the process. --- addons/account/models/account_move.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/account/models/account_move.py b/addons/account/models/account_move.py index edee204410e..21e70f83ff9 100644 --- a/addons/account/models/account_move.py +++ b/addons/account/models/account_move.py @@ -228,8 +228,8 @@ class AccountMove(models.Model): 'date': date, 'journal_id': journal_id.id if journal_id else self.journal_id.id, 'ref': _('reversal of: ') + self.name}) - for acm_line in reversed_move.line_ids: - acm_line.with_context(check_move_validity=False).write({ + for acm_line in reversed_move.line_ids.with_context(check_move_validity=False): + acm_line.write({ 'debit': acm_line.credit, 'credit': acm_line.debit, 'amount_currency': -acm_line.amount_currency