Merge lp:~numerigraphe/openobject-client/trunk-action-context-none into lp:openobject-client

Proposed by Numérigraphe
Status: Needs review
Proposed branch: lp:~numerigraphe/openobject-client/trunk-action-context-none
Merge into: lp:openobject-client
Diff against target: 25 lines (+8/-2)
1 file modified
bin/modules/action/main.py (+8/-2)
To merge this branch: bzr merge lp:~numerigraphe/openobject-client/trunk-action-context-none
Reviewer Review Type Date Requested Status
OpenERP sa GTK client R&D Pending
Review via email: mp+95210@code.launchpad.net

Description of the change

This branch makes sure the default context is immutable in _exec_action() and fixes a bug in reading the context from action.

To post a comment you must log in.

Unmerged revisions

2052. By Numerigraphe - Lionel Sausin <email address hidden>

[FIX] set the action context to {} when it's explicitly passed as None

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bin/modules/action/main.py'
2--- bin/modules/action/main.py 2011-12-09 11:22:31 +0000
3+++ bin/modules/action/main.py 2012-02-29 16:58:18 +0000
4@@ -86,13 +86,19 @@
5 res = rpc.session.rpc_exec_auth('/object', 'execute', type, 'read', act_id, False, ctx)
6 self._exec_action(res,datas,context)
7
8- def _exec_action(self, action, datas, context={}):
9+ def _exec_action(self, action, datas, context=None):
10+ if context is None:
11+ context = {}
12 if isinstance(action, bool) or 'type' not in action:
13 return
14 # Updating the context : Adding the context of action in order to use it on Views called from buttons
15 if datas.get('id',False):
16 context.update( {'active_id': datas.get('id',False), 'active_ids': datas.get('ids',[]), 'active_model': datas.get('model',False)})
17- context.update(tools.expr_eval(action.get('context','{}'), context.copy()))
18+ # set a default context even if action.get('context') is explicitly None
19+ act_context = action.get('context')
20+ if act_context is None:
21+ act_context = {}
22+ context.update(tools.expr_eval(act_context, context.copy()))
23 if action['type'] in ['ir.actions.act_window', 'ir.actions.submenu']:
24 for key in ('res_id', 'res_model', 'view_type', 'view_mode',
25 'limit', 'auto_refresh', 'search_view', 'auto_search', 'search_view_id'):