From 1834b80bfa2e259b0127d462a84225fab14fe39d Mon Sep 17 00:00:00 2001 From: Cedric Snauwaert Date: Fri, 15 Mar 2019 13:01:00 +0000 Subject: [PATCH] [FIX] account: error in concurrent update while reconciling In reconciliation widget, when clicking reconcile with some existing line. if by any chance the transaction gets rolled back because of a concurrent update, the next replay attempt will use the modified parameters, and we will get a KeyError. Retrying the operation will succeed as soon as no other transaction conflicts again. Altering mutable RPC parameters is a bit risky in a public RPC method, particularly when those altered parameters will modify the effect of the method. Making a deepcopy of the parameters before using them is an easy workaround. The framework does not do it by default because of the hard-to-foresee memory overhead it would have. fixes #25403 closes odoo/odoo#31882 Signed-off-by: Cedric Snauwaert (csn) --- addons/account/models/account_bank_statement.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/addons/account/models/account_bank_statement.py b/addons/account/models/account_bank_statement.py index 23ba4470035..3446479ba18 100644 --- a/addons/account/models/account_bank_statement.py +++ b/addons/account/models/account_bank_statement.py @@ -9,6 +9,7 @@ from odoo.exceptions import UserError, ValidationError import time import math +import copy class AccountCashboxLine(models.Model): """ Cash Box Details """ @@ -811,9 +812,10 @@ class AccountBankStatementLine(models.Model): :param list of dicts data: must contains the keys 'counterpart_aml_dicts', 'payment_aml_ids' and 'new_aml_dicts', whose value is the same as described in process_reconciliation except that ids are used instead of recordsets. """ + data_copy = copy.deepcopy(data) AccountMoveLine = self.env['account.move.line'] ctx = dict(self._context, force_price_include=False) - for st_line, datum in pycompat.izip(self, data): + for st_line, datum in pycompat.izip(self, data_copy): payment_aml_rec = AccountMoveLine.browse(datum.get('payment_aml_ids', [])) for aml_dict in datum.get('counterpart_aml_dicts', []): aml_dict['move_line'] = AccountMoveLine.browse(aml_dict['counterpart_aml_id'])