From f73907587b0e4d5a11e30b01adc42e63c437572a Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Thu, 24 Apr 2014 13:03:41 +0200 Subject: [PATCH] [FIX] gamification: do not set a start_date by default as the cron starts past challenges (making data challenge to start) and avoid useless write bzr revid: mat@openerp.com-20140424110341-pnu79q44m7gzl8t0 --- addons/gamification/models/challenge.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/addons/gamification/models/challenge.py b/addons/gamification/models/challenge.py index 8ac7753898f..b5322321689 100644 --- a/addons/gamification/models/challenge.py +++ b/addons/gamification/models/challenge.py @@ -199,7 +199,6 @@ class gamification_challenge(osv.Model): 'visibility_mode': 'personal', 'report_message_frequency': 'never', 'last_report_date': fields.date.today, - 'start_date': fields.date.today, 'manager_id': lambda s, cr, uid, c: uid, 'category': 'hr', 'reward_failure': False, @@ -284,13 +283,15 @@ class gamification_challenge(osv.Model): planned_challenge_ids = self.search(cr, uid, [ ('state', '=', 'draft'), ('start_date', '<=', fields.date.today())]) - self.write(cr, uid, planned_challenge_ids, {'state': 'inprogress'}, context=context) + if planned_challenge_ids: + self.write(cr, uid, planned_challenge_ids, {'state': 'inprogress'}, context=context) # close planned challenges planned_challenge_ids = self.search(cr, uid, [ ('state', '=', 'inprogress'), ('end_date', '>=', fields.date.today())]) - self.write(cr, uid, planned_challenge_ids, {'state': 'done'}, context=context) + if planned_challenge_ids: + self.write(cr, uid, planned_challenge_ids, {'state': 'done'}, context=context) if not ids: ids = self.search(cr, uid, [('state', '=', 'inprogress')], context=context)