[FIX] actions: match the behavior of multi actions with its help text
authorXavier Morel <xmo@openerp.com>
Wed, 8 Oct 2014 11:07:32 +0000 (13:07 +0200)
committerXavier Morel <xmo@openerp.com>
Wed, 8 Oct 2014 15:29:36 +0000 (17:29 +0200)
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
openerp/addons/base/tests/test_ir_actions.py

index 1d01b05..65e913a 100644 (file)
@@ -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.
index 68e7a54..1d950e3 100644 (file)
@@ -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__':