Merge lp:~camptocamp/ocb-addons/ocb-7.0-fix_action_rule_processing_lp1190592-afe into lp:ocb-addons

Proposed by Alexandre Fayolle - camptocamp
Status: Merged
Approved by: Holger Brunn (Therp)
Approved revision: no longer in the source branch.
Merged at revision: 10037
Proposed branch: lp:~camptocamp/ocb-addons/ocb-7.0-fix_action_rule_processing_lp1190592-afe
Merge into: lp:ocb-addons
Diff against target: 17 lines (+6/-1)
1 file modified
base_action_rule/base_action_rule.py (+6/-1)
To merge this branch: bzr merge lp:~camptocamp/ocb-addons/ocb-7.0-fix_action_rule_processing_lp1190592-afe
Reviewer Review Type Date Requested Status
Yann Papouin code review Approve
Leonardo Pistone code review Approve
Holger Brunn (Therp) code review Approve
Pedro Manuel Baeza code review Approve
Review via email: mp+209086@code.launchpad.net

Description of the change

fix issue with action being erroneously repeated.

Port of https://code.launchpad.net/~camptocamp/openobject-addons/7.0-fix_action_rule_processing_lp1190592-afe/+merge/209077

Note that there is another MP on openobject-addons for this bug, which I personnaly find less clear (https://code.launchpad.net/~elbati/openobject-addons/7.0_fix_action_rule_processing/+merge/169191). If people think that the latter is better, just say so in the reviews and I'll update the ocb MP accordingly.

To post a comment you must log in.
Revision history for this message
Pedro Manuel Baeza (pedro.baeza) wrote :

Indeed, a misuse of the one line sentences.

Regards.

review: Approve (code review)
Revision history for this message
Holger Brunn (Therp) (hbrunn) wrote :

what we want is

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

review: Approve (code review)
Revision history for this message
Leonardo Pistone (lepistone) :
review: Approve (code review)
Revision history for this message
Yann Papouin (yann-papouin) wrote :

This one is better to understand

review: Approve (code review)

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 2014-02-12 11:39:24 +0000
3+++ base_action_rule/base_action_rule.py 2014-03-03 15:24:04 +0000
4@@ -266,7 +266,12 @@
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: # don't try to put everything in a one-liner or
10+ # risk being bitten by lp:1190592
11+ needs_process = (last_run <= action_dt < now)
12+ else:
13+ needs_process = (action_dt < now)
14+ if needs_process:
15 try:
16 self._process(cr, uid, action, [record.id], context=context)
17 except Exception: