From 7ad2eb354d89a59970add57feaa1b4945a883f4c Mon Sep 17 00:00:00 2001 From: Richard Mathot Date: Tue, 17 Jun 2014 11:45:30 +0200 Subject: [PATCH] [IMP] base: use current context when evaluation ir_actions' context --- openerp/addons/base/ir/ir_actions.py | 36 +++++++++++++++------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/openerp/addons/base/ir/ir_actions.py b/openerp/addons/base/ir/ir_actions.py index c41eae84ff8..7ae4240cd03 100644 --- a/openerp/addons/base/ir/ir_actions.py +++ b/openerp/addons/base/ir/ir_actions.py @@ -320,22 +320,26 @@ class ir_actions_act_window(osv.osv): ids = [ids] results = super(ir_actions_act_window, self).read(cr, uid, ids, fields=fields, context=context, load=load) - if not fields or 'help' in fields: - context = dict(context or {}) - eval_dict = { - 'active_model': context.get('active_model'), - 'active_id': context.get('active_id'), - 'active_ids': context.get('active_ids'), - 'uid': uid, - } - for res in results: - model = res.get('res_model') - if model and self.pool.get(model): - try: - with tools.mute_logger("openerp.tools.safe_eval"): - eval_context = eval(res['context'] or "{}", eval_dict) or {} - except Exception: - continue + context = dict(context or {}) + eval_dict = { + 'active_model': context.get('active_model'), + 'active_id': context.get('active_id'), + 'active_ids': context.get('active_ids'), + 'uid': uid, + 'context': context, + } + for res in results: + model = res.get('res_model') + if model and self.pool.get(model): + try: + with tools.mute_logger("openerp.tools.safe_eval"): + eval_context = eval(res['context'] or "{}", eval_dict) or {} + res['context'] = str(eval_context) + except Exception: + _logger.warning("ir_actions: Cannot evaluate context = %s with eval_dict = %s" + % (res['context'] or "{}", eval_dict), exc_info=True) + continue + if not fields or 'help' in fields: custom_context = dict(context, **eval_context) res['help'] = self.pool.get(model).get_empty_list_help(cr, uid, res.get('help', ""), context=custom_context) if ids_int: