[FIX] Fixed active_ids / active_id management, wrong getter on active_id making server action run twice.
bzr revid: tde@openerp.com-20130716082344-cvw0djli0n8pq3bt
This commit is contained in:
parent
8397f3de47
commit
a95b321883
|
@ -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
|
||||
|
|
|
@ -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')])
|
||||
|
|
Loading…
Reference in New Issue