Merge lp:~elbati/openobject-addons/7.0_fix_action_rule_processing into lp:openobject-addons/7.0

Proposed by Lorenzo Battistini
Status: Needs review
Proposed branch: lp:~elbati/openobject-addons/7.0_fix_action_rule_processing
Merge into: lp:openobject-addons/7.0
Diff against target: 13 lines (+2/-1)
1 file modified
base_action_rule/base_action_rule.py (+2/-1)
To merge this branch: bzr merge lp:~elbati/openobject-addons/7.0_fix_action_rule_processing
Reviewer Review Type Date Requested Status
Lorenzo Battistini (community) Abstain
Leonardo Pistone (community) Abstain
Alexandre Fayolle - camptocamp (community) Abstain
OpenERP Core Team Pending
Review via email: mp+169191@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Yannick Vaucher @ Camptocamp (yvaucher-c2c) wrote :

I admire the way you did use the ternary operator but wouldn't it be more readable that way?

if last_run and (last_run <= action_dt < now)
   or not last_run and (action_dt < now):

I think using it in a comparison make things a bit confusing

Or maybe just add indentation to the second line to keep clear it is still the comparison.

Revision history for this message
Leonardo Pistone (lepistone) wrote :

Yannick,

There is some explanation of why I suggest to use the ternary operator on the bug linked to this MP:
https://bugs.launchpad.net/openobject-addons/+bug/1190592

In short, the and-or trick doesn't behave as expected when the second condition is false, and that is what happens here. The inline if-else is unaffected by that.

review: Approve
Revision history for this message
Lorenzo Battistini (elbati) :
review: Approve
Revision history for this message
Alexandre Fayolle - camptocamp (alexandre-fayolle-c2c) wrote :

I'd really like if a more readable / maintainable formulation was used.

I made another proposal with this in mind (https://code.launchpad.net/~camptocamp/openobject-addons/7.0-fix_action_rule_processing_lp1190592-afe/+merge/209077).

review: Abstain
Revision history for this message
Leonardo Pistone (lepistone) wrote :

Alexandre, no problem for me to take your version.

I change my review to abstain.

review: Abstain
Revision history for this message
Lorenzo Battistini (elbati) :
review: Abstain

Unmerged revisions

9193. By Lorenzo Battistini

[FIX] rule processing time

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'base_action_rule/base_action_rule.py'
2--- base_action_rule/base_action_rule.py 2013-05-29 10:42:02 +0000
3+++ base_action_rule/base_action_rule.py 2013-06-13 13:07:42 +0000
4@@ -256,7 +256,8 @@
5 if not record_dt:
6 continue
7 action_dt = get_datetime(record_dt) + delay
8- if last_run and (last_run <= action_dt < now) or (action_dt < now):
9+ if ((last_run <= action_dt < now) if last_run
10+ else action_dt < now):
11 try:
12 self._process(cr, uid, action, [record.id], context=context)
13 except Exception: