From 8cfe731f769f8b2c30ddad2d4cfeaea2eefd9523 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Wed, 8 Oct 2014 13:07:32 +0200 Subject: [PATCH] [FIX] actions: match the behavior of multi actions with its help text also fix the corresponding text and add explicit sequence number because I don't understand what the bloody hell it does without that, except that it's not the right thing. At all. --- openerp/addons/base/ir/ir_actions.py | 8 ++++---- openerp/addons/base/tests/test_ir_actions.py | 21 ++++++++++++++------ 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/openerp/addons/base/ir/ir_actions.py b/openerp/addons/base/ir/ir_actions.py index 1d01b05154d..65e913a06f4 100644 --- a/openerp/addons/base/ir/ir_actions.py +++ b/openerp/addons/base/ir/ir_actions.py @@ -877,12 +877,12 @@ class ir_actions_server(osv.osv): workflow.trg_validate(uid, target_pool._name, target_id, trigger_name, cr) def run_action_multi(self, cr, uid, action, eval_context=None, context=None): - res = [] + res = False for act in action.child_ids: - result = self.run(cr, uid, [act.id], context) + result = self.run(cr, uid, [act.id], context=context) if result: - res.append(result) - return res and res[0] or False + res = result + return res def run_action_object_write(self, cr, uid, action, eval_context=None, context=None): """ Write server action. diff --git a/openerp/addons/base/tests/test_ir_actions.py b/openerp/addons/base/tests/test_ir_actions.py index 68e7a54d7f5..1d950e325ef 100644 --- a/openerp/addons/base/tests/test_ir_actions.py +++ b/openerp/addons/base/tests/test_ir_actions.py @@ -364,20 +364,28 @@ workflow""" # Data: 2 server actions that will be nested act1_id = self.ir_actions_server.create(cr, uid, { 'name': 'Subaction1', + 'sequence': 1, 'model_id': self.res_partner_model_id, 'state': 'code', 'code': 'action = {"type": "ir.actions.act_window"}', }) - # Do: create a new record in the same model and link it act2_id = self.ir_actions_server.create(cr, uid, { 'name': 'Subaction2', + 'sequence': 2, 'model_id': self.res_partner_model_id, 'state': 'object_create', 'use_create': 'copy_current', }) + act3_id = self.ir_actions_server.create(cr, uid, { + 'name': 'Subaction3', + 'sequence': 3, + 'model_id': self.res_partner_model_id, + 'state': 'code', + 'code': 'action = {"type": "ir.actions.act_url"}', + }) self.ir_actions_server.write(cr, uid, [self.act_id], { 'state': 'multi', - 'child_ids': [(6, 0, [act1_id, act2_id])], + 'child_ids': [(6, 0, [act1_id, act2_id, act3_id])], }) # Do: run the action @@ -387,12 +395,13 @@ workflow""" pids = self.res_partner.search(cr, uid, [('name', 'ilike', 'TestingPartner (copy)')]) # currently res_partner overrides default['name'] whatever its value self.assertEqual(len(pids), 1, 'ir_actions_server: TODO') # Test: action returned - self.assertEqual(res.get('type'), 'ir.actions.act_window', '') + self.assertEqual(res.get('type'), 'ir.actions.act_url') # Test loops - self.assertRaises(except_orm, self.ir_actions_server.write, cr, uid, [self.act_id], { - 'child_ids': [(6, 0, [self.act_id])] - }) + with self.assertRaises(except_orm): + self.ir_actions_server.write(cr, uid, [self.act_id], { + 'child_ids': [(6, 0, [self.act_id])] + }) if __name__ == '__main__':