[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) <csn@openerp.com>
This commit is contained in:
@@ -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'])
|
||||
|
||||
Reference in New Issue
Block a user