summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Trigaux <mat@openerp.com>2014-05-14 10:59:20 +0200
committerMartin Trigaux <mat@openerp.com>2014-05-14 10:59:20 +0200
commit3ff7b48a811bf04aafa70a6ce0db73122cee4bcc (patch)
tree24c73802f90ab7fe3225c88bef481e09dfad8c3d
parent8ea4f581ed3f34cbfbfb069cd459af4569b11fa3 (diff)
[FIX] gamification: make sure than a cron running more than once a day will not report the progress more than once
-rw-r--r--addons/gamification/models/challenge.py27
1 files changed, 14 insertions, 13 deletions
diff --git a/addons/gamification/models/challenge.py b/addons/gamification/models/challenge.py
index 8ed3890ce69..222e5cca49e 100644
--- a/addons/gamification/models/challenge.py
+++ b/addons/gamification/models/challenge.py
@@ -329,19 +329,20 @@ class gamification_challenge(osv.Model):
self.write(cr, uid, [challenge.id], {'user_ids': [(4, user.id) for user in challenge.autojoin_group_id.users]}, context=context)
self.generate_goals_from_challenge(cr, uid, [challenge.id], context=context)
- # goals closed but still opened at the last report date
- closed_goals_to_report = goal_obj.search(cr, uid, [
- ('challenge_id', '=', challenge.id),
- ('start_date', '>=', challenge.last_report_date),
- ('end_date', '<=', challenge.last_report_date)
- ])
-
- if len(closed_goals_to_report) > 0:
- # some goals need a final report
- self.report_progress(cr, uid, challenge, subset_goal_ids=closed_goals_to_report, context=context)
-
- if fields.date.today() == challenge.next_report_date:
- self.report_progress(cr, uid, challenge, context=context)
+ if challenge.last_report_date != fields.date.today():
+ # goals closed but still opened at the last report date
+ closed_goals_to_report = goal_obj.search(cr, uid, [
+ ('challenge_id', '=', challenge.id),
+ ('start_date', '>=', challenge.last_report_date),
+ ('end_date', '<=', challenge.last_report_date)
+ ])
+
+ if fields.date.today() >= challenge.next_report_date:
+ self.report_progress(cr, uid, challenge, context=context)
+
+ elif len(closed_goals_to_report) > 0:
+ # some goals need a final report
+ self.report_progress(cr, uid, challenge, subset_goal_ids=closed_goals_to_report, context=context)
self.check_challenge_reward(cr, uid, ids, context=context)
return True