From adf8b29451f42eca48e33cd6a7172515de3d5bbf Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Thu, 28 Feb 2013 17:35:13 +0100 Subject: [PATCH] [FIX] gamification: send to user if no groups bzr revid: mat@openerp.com-20130228163513-jb7pbs8xuiyoyuql --- addons/gamification/goal.py | 2 +- addons/gamification/plan.py | 22 +++++++++---------- .../templates/group_progress.mako | 4 ++-- .../templates/personal_progress.mako | 13 ++++++----- addons/gamification/templates/reminder.mako | 6 ++--- 5 files changed, 24 insertions(+), 23 deletions(-) diff --git a/addons/gamification/goal.py b/addons/gamification/goal.py index 5660084fa77..95e55fe4ab5 100644 --- a/addons/gamification/goal.py +++ b/addons/gamification/goal.py @@ -223,7 +223,7 @@ class gamification_goal(osv.Model): else: # computation mode = count res = obj.search(cr, uid, domain, context=context) towrite = {'current': len(res)} - + print(domain, res) # check goal target reached if (goal.type_id.condition == 'plus' \ and towrite['current'] >= goal.target_goal) \ diff --git a/addons/gamification/plan.py b/addons/gamification/plan.py index 8c31dcd57c7..b731f7af67b 100644 --- a/addons/gamification/plan.py +++ b/addons/gamification/plan.py @@ -338,9 +338,6 @@ class gamification_goal_plan(osv.Model): template_env = TemplateHelper() for plan in self.browse(cr, uid, ids, context=context): - if not plan.report_message_group_id: - # no report group, skipping - continue if plan.visibility_mode == 'board': # generate a shared report @@ -372,15 +369,17 @@ class gamification_goal_plan(osv.Model): planlines_boards.append({'goal_type':planline.type_id.name, 'board_goals':sorted_board}) body_html = template_env.get_template('group_progress.mako').render({'object':plan, 'planlines_boards':planlines_boards}) + print(body_html) self.message_post(cr, uid, plan.id, body=body_html, partner_ids=[user.partner_id.id for user in plan.user_ids], context=context, subtype='mail.mt_comment') - self.pool.get('mail.group').message_post(cr, uid, plan.report_message_group_id.id, - body=body_html, - context=context, - subtype='mail.mt_comment') + if plan.report_message_group_id: + self.pool.get('mail.group').message_post(cr, uid, plan.report_message_group_id.id, + body=body_html, + context=context, + subtype='mail.mt_comment') else: # generate individual reports @@ -401,10 +400,11 @@ class gamification_goal_plan(osv.Model): partner_ids=[user.partner_id.id], context=context, subtype='mail.mt_comment') - self.pool.get('mail.group').message_post(cr, uid, plan.report_message_group_id.id, - body=body_html, - context=context, - subtype='mail.mt_comment') + if plan.report_message_group_id: + self.pool.get('mail.group').message_post(cr, uid, plan.report_message_group_id.id, + body=body_html, + context=context, + subtype='mail.mt_comment') return True diff --git a/addons/gamification/templates/group_progress.mako b/addons/gamification/templates/group_progress.mako index a815b711114..332711fd1e4 100644 --- a/addons/gamification/templates/group_progress.mako +++ b/addons/gamification/templates/group_progress.mako @@ -9,8 +9,8 @@

${object.report_header or ''}

- - % for planline in planlines_boards: +

+ % for planline in planlines_boards: diff --git a/addons/gamification/templates/personal_progress.mako b/addons/gamification/templates/personal_progress.mako index a7325760b56..3c4e48f82a1 100644 --- a/addons/gamification/templates/personal_progress.mako +++ b/addons/gamification/templates/personal_progress.mako @@ -5,13 +5,11 @@
- % if object.report_header - ${object.report_header} - % endif -
- -

Below are the latest results for the plan ${object.name} for ${user.name}.

+ ${object.name} + +

${object.report_header or ''}

+

@@ -26,6 +24,9 @@ + +

+ % endfor
Goal${goal.current} ${goal.completeness} %
\ No newline at end of file diff --git a/addons/gamification/templates/reminder.mako b/addons/gamification/templates/reminder.mako index 9e161dcef0e..632467eb771 100644 --- a/addons/gamification/templates/reminder.mako +++ b/addons/gamification/templates/reminder.mako @@ -5,10 +5,10 @@
- % if object.report_header - ${object.report_header} - % endif + Reminder ${object.name}
+ +

${object.report_header or ''}

You have not updated your progress for the goal ${object.type_id.name} (currently reached at ${object.completeness}%) for at least ${object.remind_update_delay}. Do not forget to do it.