From 9e025b95a8384e846d97d779944ba93c55500770 Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Mon, 4 Mar 2013 16:31:38 +0100 Subject: [PATCH] [IMP] add autojoin group users for goal plan start bzr revid: mat@openerp.com-20130304153138-n35mawq0ffbtypj7 --- addons/gamification/plan.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/addons/gamification/plan.py b/addons/gamification/plan.py index 881e08fdea5..e015d0865c6 100644 --- a/addons/gamification/plan.py +++ b/addons/gamification/plan.py @@ -182,7 +182,8 @@ class gamification_goal_plan(osv.Model): # add users when change the group auto-subscription if 'autojoin_group_id' in vals: new_group = self.pool.get('res.groups').browse(cr, uid, vals['autojoin_group_id'], context=context) - self.plan_subscribe_users(cr, uid, ids, [user.id for user in new_group.users], context=context) + if new_group: + self.plan_subscribe_users(cr, uid, ids, [user.id for user in new_group.users], context=context) return write_res @@ -235,6 +236,11 @@ class gamification_goal_plan(osv.Model): """Start a draft goal plan Change the state of the plan to in progress""" + # subscribe users if autojoin group + for plan in self.browse(cr, uid, ids, context=context): + if plan.autojoin_group_id: + self.plan_subscribe_users(cr, uid, ids, [user.id for user in plan.autojoin_group_id.users], context=context) + self.generate_goals_from_plan(cr, uid, ids, context=context) return self.write(cr, uid, ids, {'state': 'inprogress'}, context=context) @@ -488,7 +494,7 @@ class gamification_goal_plan(osv.Model): context=context, subtype='mail.mt_comment') return True - + class gamification_goal_planline(osv.Model): """Gamification goal planline