[FIX] Fixed active_ids / active_id management, wrong getter on active_id making serve...
authorThibault Delavallée <tde@openerp.com>
Tue, 16 Jul 2013 08:23:44 +0000 (10:23 +0200)
committerThibault Delavallée <tde@openerp.com>
Tue, 16 Jul 2013 08:23:44 +0000 (10:23 +0200)
bzr revid: tde@openerp.com-20130716082344-cvw0djli0n8pq3bt

openerp/addons/base/ir/ir_actions.py
openerp/addons/base/tests/test_ir_actions.py

index 54bfe0e..3e8b4a7 100644 (file)
@@ -895,13 +895,15 @@ class actions_server(osv.osv):
             context = {}
         res = False
         user = self.pool.get('res.users').browse(cr, uid, uid)
-        active_ids = context.get('active_ids', [context.get('active_id'), None])
+        active_ids = context.get('active_ids', [context.get('active_id', None)])
         for action in self.browse(cr, uid, ids, context):
             obj = None
             obj_pool = self.pool[action.model_id.model]
             for active_id in active_ids:
                 if context.get('active_model') == action.model_id.model and active_id:
                     obj = obj_pool.browse(cr, uid, context['active_id'], context=context)
+                # run context dedicated to a particular active_id
+                run_context = dict(context, active_ids=[active_id], active_id=active_id)
                 # evaluation context for python strings to evaluate
                 eval_context = {
                     'self': obj_pool,
@@ -910,12 +912,10 @@ class actions_server(osv.osv):
                     'pool': self.pool,
                     'time': time,
                     'cr': cr,
-                    'context': dict(context),  # copy context to prevent side-effects of eval
+                    'context': dict(run_context),  # copy context to prevent side-effects of eval
                     'uid': uid,
                     'user': user
                 }
-                # run context dedicated to a particular active_id
-                run_context = dict(context, active_id=active_id)
 
                 # evaluate the condition, with the specific case that a void (aka False) condition is considered as True
                 condition = action.condition
index 63ed586..c0e1de1 100644 (file)
@@ -97,7 +97,7 @@ class TestServerActions(TestServerActionsBase):
             'code': """partner_name = obj.name + '_code'
 self.pool["res.partner"].create(cr, uid, {"name": partner_name}, context=context)"""
         })
-        run_res = self.ir_actions_server.run(cr, uid, [self.act_id], self.context)
+        run_res = self.ir_actions_server.run(cr, uid, [self.act_id], context=self.context)
         self.assertFalse(run_res, 'ir_actions_server: code server action correctly finished should return False')
 
         pids = self.res_partner.search(cr, uid, [('name', 'ilike', 'TestingPartner_code')])