[FIX] gamification: send to user if no groups

bzr revid: mat@openerp.com-20130228163513-jb7pbs8xuiyoyuql
This commit is contained in:
Martin Trigaux 2013-02-28 17:35:13 +01:00
parent 402f30284c
commit adf8b29451
5 changed files with 24 additions and 23 deletions

View File

@ -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) \

View File

@ -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

View File

@ -9,8 +9,8 @@
</header>
<p class="oe_grey">${object.report_header or ''}</p>
% for planline in planlines_boards:
<br/><br/>
% for planline in planlines_boards:
<table width="100%" border="1">
<tr>

View File

@ -5,13 +5,11 @@
</head>
<body>
<header>
% if object.report_header
${object.report_header}
% endif
</header>
<p>Below are the latest results for the plan ${object.name} for ${user.name}.</p>
<strong>${object.name}</strong>
</header>
<p class="oe_grey">${object.report_header or ''}</p>
<br/><br/>
<table width="100%" border="1">
<tr>
<th>Goal</th>
@ -26,6 +24,9 @@
<td>${goal.current}</td>
<td>${goal.completeness} %</td>
</tr>
<br/><br/>
% endfor
</table>
</body>

View File

@ -5,10 +5,10 @@
</head>
<body>
<header>
% if object.report_header
${object.report_header}
% endif
<strong>Reminder ${object.name}</strong>
</header>
<p class="oe_grey">${object.report_header or ''}</p>
<p>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.</p>