[IMP] base: use current context when evaluation ir_actions' context
authorRichard Mathot <rim@openerp.com>
Tue, 17 Jun 2014 09:45:30 +0000 (11:45 +0200)
committerRichard Mathot <rim@openerp.com>
Tue, 17 Jun 2014 09:59:14 +0000 (11:59 +0200)
openerp/addons/base/ir/ir_actions.py

index c41eae8..7ae4240 100644 (file)
@@ -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: