From a5c0a338636a3ebd129e6ef36bfbf8809a4b6fd2 Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Fri, 22 Feb 2013 15:22:12 +0100 Subject: [PATCH] [IMP] gamification: resume canceled goals bzr revid: mat@openerp.com-20130222142212-ioirjxt3axxh58li --- addons/gamification/goal.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/addons/gamification/goal.py b/addons/gamification/goal.py index 8f38e718773..3c1619b26c7 100644 --- a/addons/gamification/goal.py +++ b/addons/gamification/goal.py @@ -427,8 +427,16 @@ class gamification_goal_plan(osv.Model): if start_date: domain.append(('start_date', '=', start_date.isoformat())) - # skip if goal already exist + # goal existing for this planline ? if len(goal_obj.search(cr, uid, domain, context=context)) > 0: + + # resume canceled goals + domain.append(('state', '=', 'canceled')) + canceled_goal_ids = goal_obj.search(cr, uid, domain, context=context) + goal_obj.write(cr, uid, canceled_goal_ids, {'state': 'inprogress'}, context=context) + goal_obj.update(cr, uid, canceled_goal_ids, context=context) + + # skip to next user continue values = { @@ -456,7 +464,8 @@ class gamification_goal_plan(osv.Model): values['remind_update_delay'] = planline.plan_id.remind_update_delay new_goal_id = goal_obj.create(cr, uid, values, context) - #self.update(cr, uid, [new_goal_id], context=context) + + goal_obj.update(cr, uid, [new_goal_id], context=context) return True