Skip to content

Commit 65c685a

Browse files
gurneyalexrco-odoo
authored andcommitted
[FIX] context mutations (odoo#10368)
when extending these methods with the new api, the context is a frozendict so we need to copy before mutating. this patch was made by searching for key addition to context and calls to the update() method on the 8.0 addons, and checking if a copy was made before in the method.
1 parent f4aae1c commit 65c685a

File tree

6 files changed

+8
-14
lines changed

6 files changed

+8
-14
lines changed

addons/account/account.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -2303,8 +2303,7 @@ def generate(self, cr, uid, ids, data=None, context=None):
23032303
pt_obj = self.pool.get('account.payment.term')
23042304
period_obj = self.pool.get('account.period')
23052305

2306-
if context is None:
2307-
context = {}
2306+
context = dict(context or {})
23082307

23092308
if data.get('date', False):
23102309
context = dict(context)

addons/account/account_move_line.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -674,8 +674,7 @@ def _check_currency_company(self, cr, uid, ids, context=None):
674674

675675
#TODO: ONCHANGE_ACCOUNT_ID: set account_tax_id
676676
def onchange_currency(self, cr, uid, ids, account_id, amount, currency_id, date=False, journal=False, context=None):
677-
if context is None:
678-
context = {}
677+
context = dict(context or {})
679678
account_obj = self.pool.get('account.account')
680679
journal_obj = self.pool.get('account.journal')
681680
currency_obj = self.pool.get('res.currency')
@@ -1090,8 +1089,7 @@ def reconcile(self, cr, uid, ids, type='auto', writeoff_acc_id=False, writeoff_p
10901089
return r_id
10911090

10921091
def view_header_get(self, cr, user, view_id, view_type, context=None):
1093-
if context is None:
1094-
context = {}
1092+
context = dict(context or {})
10951093
context = self.convert_to_period(cr, user, context=context)
10961094
if context.get('account_id', False):
10971095
cr.execute('SELECT code FROM account_account WHERE id = %s', (context['account_id'], ))

addons/account/wizard/account_report_general_ledger.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,7 @@ def onchange_fiscalyear(self, cr, uid, ids, fiscalyear=False, context=None):
4949
return res
5050

5151
def _print_report(self, cr, uid, ids, data, context=None):
52-
if context is None:
53-
context = {}
52+
context = dict(context or {})
5453
data = self.pre_print_report(cr, uid, ids, data, context=context)
5554
data['form'].update(self.read(cr, uid, ids, ['landscape', 'initial_balance', 'amount_currency', 'sortby'])[0])
5655
if not data['form']['fiscalyear_id']:# GTK client problem onchange does not consider in save record

addons/document/document.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -620,9 +620,8 @@ class node_context(object):
620620
def __init__(self, cr, uid, context=None):
621621
self.dbname = cr.dbname
622622
self.uid = uid
623+
context = dict(context or {})
623624
self.context = context
624-
if context is None:
625-
context = {}
626625
context['uid'] = uid
627626
self._dirobj = openerp.registry(cr.dbname).get('document.directory')
628627
self.node_file_class = node_file

addons/l10n_be/wizard/l10n_be_partner_vat_listing.py

+1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ class partner_vat(osv.osv_memory):
4545
_name = "partner.vat"
4646

4747
def get_partner(self, cr, uid, ids, context=None):
48+
context = dict(context or {})
4849
obj_period = self.pool.get('account.period')
4950
obj_partner = self.pool.get('res.partner')
5051
obj_vat_lclient = self.pool.get('vat.listing.clients')

addons/point_of_sale/point_of_sale.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -443,8 +443,7 @@ def open_cb(self, cr, uid, ids, context=None):
443443
"""
444444
call the Point Of Sale interface and set the pos.session to 'opened' (in progress)
445445
"""
446-
if context is None:
447-
context = dict()
446+
context = dict(context or {})
448447

449448
if isinstance(ids, (int, long)):
450449
ids = [ids]
@@ -537,8 +536,7 @@ def _confirm_orders(self, cr, uid, ids, context=None):
537536
return True
538537

539538
def open_frontend_cb(self, cr, uid, ids, context=None):
540-
if not context:
541-
context = {}
539+
context = dict(context or {})
542540
if not ids:
543541
return {}
544542
for session in self.browse(cr, uid, ids, context=context):

0 commit comments

Comments
 (0)