[14.0][FIX] Keep original kwargs intact for reuse on retry
closes odoo/odoo#79589 X-original-commit: 6387619d308c8969cbafe6acf77f6d22075ac6ba Signed-off-by: Raphael Collet (rco) <rco@openerp.com> Co-authored-by: Raphael Collet <rco@odoo.com>
This commit is contained in:
committed by
Raphael Collet
co-authored by
Raphael Collet
parent
8b6742cb83
commit
8f574a274a
@@ -1,7 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo import models, Command
|
||||
from odoo import api, models, Command
|
||||
from odoo.addons.base.tests.common import SavepointCaseWithUserDemo
|
||||
from odoo.tools import mute_logger
|
||||
from odoo.exceptions import AccessError
|
||||
@@ -523,3 +523,14 @@ class TestAPI(SavepointCaseWithUserDemo):
|
||||
# sort by inverse name, with a field name
|
||||
by_name_ids = [p.id for p in sorted(ps, key=lambda p: p.name, reverse=True)]
|
||||
self.assertEqual(ps.sorted('name', reverse=True).ids, by_name_ids)
|
||||
|
||||
|
||||
class TestExternalAPI(SavepointCaseWithUserDemo):
|
||||
|
||||
def test_call_kw(self):
|
||||
"""kwargs is not modified by the execution of the call"""
|
||||
partner = self.env['res.partner'].create({'name': 'MyPartner1'})
|
||||
args = (partner.ids, ['name'])
|
||||
kwargs = {'context': {'test': True}}
|
||||
api.call_kw(self.env['res.partner'], 'read', args, kwargs)
|
||||
self.assertEqual(kwargs, {'context': {'test': True}})
|
||||
|
||||
@@ -350,6 +350,9 @@ def split_context(method, args, kwargs):
|
||||
""" Extract the context from a pair of positional and keyword arguments.
|
||||
Return a triple ``context, args, kwargs``.
|
||||
"""
|
||||
# altering kwargs is a cause of errors, for instance when retrying a request
|
||||
# after a serialization error: the retry is done without context!
|
||||
kwargs = kwargs.copy()
|
||||
return kwargs.pop('context', None), args, kwargs
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user