Merge lp:~openerp-dev/openobject-server/trunk-eval-action-context-pna into lp:openobject-server

Proposed by Richard Mathot (Odoo, formerly OpenERP)
Status: Work in progress
Proposed branch: lp:~openerp-dev/openobject-server/trunk-eval-action-context-pna
Merge into: lp:openobject-server
Diff against target: 50 lines (+22/-17)
1 file modified
openerp/addons/base/ir/ir_actions.py (+22/-17)
To merge this branch: bzr merge lp:~openerp-dev/openobject-server/trunk-eval-action-context-pna
Reviewer Review Type Date Requested Status
Richard Mathot (Odoo, formerly OpenERP) (community) Disapprove
Review via email: mp+216827@code.launchpad.net
To post a comment you must log in.
5154. By Richard Mathot (Odoo, formerly OpenERP)

[MERGE] from trunk

Revision history for this message
Richard Mathot (Odoo, formerly OpenERP) (rim-openerp) wrote :

Seems very suspect

review: Disapprove

Unmerged revisions

5154. By Richard Mathot (Odoo, formerly OpenERP)

[MERGE] from trunk

5153. By Pinakin Nayi (OpenERP)

[Merge]with trunk

5152. By Pinakin Nayi (OpenERP)

[Merge]with trunk

5151. By Pinakin Nayi (OpenERP)

[MERGE]with main

5150. By Pinakin Nayi (OpenERP)

[IMP]act_window: eval context and append in result

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'openerp/addons/base/ir/ir_actions.py'
2--- openerp/addons/base/ir/ir_actions.py 2014-04-07 17:46:28 +0000
3+++ openerp/addons/base/ir/ir_actions.py 2014-04-23 09:58:28 +0000
4@@ -306,24 +306,29 @@
5 ids = [ids]
6 results = super(ir_actions_act_window, self).read(cr, uid, ids, fields=fields, context=context, load=load)
7
8- if not fields or 'help' in fields:
9- context = dict(context or {})
10- eval_dict = {
11- 'active_model': context.get('active_model'),
12- 'active_id': context.get('active_id'),
13- 'active_ids': context.get('active_ids'),
14- 'uid': uid,
15- }
16- for res in results:
17- model = res.get('res_model')
18- if model and self.pool.get(model):
19- try:
20- with tools.mute_logger("openerp.tools.safe_eval"):
21- eval_context = eval(res['context'] or "{}", eval_dict) or {}
22- except Exception:
23- continue
24+ context = dict(context or {})
25+ eval_dict = {
26+ 'active_model': context.get('active_model'),
27+ 'active_id': context.get('active_id'),
28+ 'active_ids': context.get('active_ids'),
29+ 'uid': uid,
30+ 'context': context,
31+ }
32+ for res in results:
33+ model = res.get('res_model')
34+ model_obj = model and self.pool.get(model) or False
35+ if model_obj:
36+ try:
37+ with tools.mute_logger("openerp.tools.safe_eval"):
38+ eval_context = eval(res['context'] or "{}", eval_dict) or {}
39+ except Exception:
40+ continue
41+ if res.get('context') and context and context.get('active_model'):
42+ custom_context = dict(**eval_context)
43+ res['context'] = str(custom_context)
44+ if not fields or 'help' in fields:
45 custom_context = dict(context, **eval_context)
46- res['help'] = self.pool.get(model).get_empty_list_help(cr, uid, res.get('help', ""), context=custom_context)
47+ res['help'] = model_obj.get_empty_list_help(cr, uid, res.get('help', ""), context=custom_context)
48 if ids_int:
49 return results[0]
50 return results