[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 eb04aa1e39

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
This commit is contained in:
Denis Ledoux
2017-01-26 10:59:58 +01:00
parent f23394b83a
commit 5ea8d4ea33
+1
View File
@@ -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