From 5ea8d4ea33258d3a1decf388a94f011f1e1e4579 Mon Sep 17 00:00:00 2001 From: Denis Ledoux Date: Thu, 26 Jan 2017 10:58:23 +0100 Subject: [PATCH] [FIX] base: fix local variable 'res' referenced before assignment In the loop `for action in self`, if all iterations passed in the first `if` block only, res was never assigned, but returned. This is an oversight during the conversion of the module to the new API in revision eb04aa1e395d347c474181e90f8c8eded1d17ca3 One could ask himself why `res = False` is before the loop and not in this `if` block, but we believe this is in the case multiple actions are passed to this method, you wouldn't like the result of the first actions in the loop to be overwritten by `False` when the condition of the last action of the loop is not met. For instance the first action returns as result an action but for the second, the condition to run it is not met, in such a case you would like what the first action returned as action. opw-706150 --- openerp/addons/base/ir/ir_actions.py | 1 + 1 file changed, 1 insertion(+) diff --git a/openerp/addons/base/ir/ir_actions.py b/openerp/addons/base/ir/ir_actions.py index 2f58c46042a..d4a6fc7bf7c 100644 --- a/openerp/addons/base/ir/ir_actions.py +++ b/openerp/addons/base/ir/ir_actions.py @@ -948,6 +948,7 @@ class IrActionsServer(models.Model): :return: an action_id to be executed, or False is finished correctly without return action """ + res = False for action in self: eval_context = self._get_eval_context(action) condition = action.condition