[FIX] gamification: send messages correctly
bzr revid: mat@openerp.com-20130228092247-v5jv7xt0mlsav4jx
This commit is contained in:
parent
d11f2a265a
commit
9e1df28731
|
@ -324,7 +324,11 @@ class gamification_goal(osv.Model):
|
|||
"""Overwrite the write method to update the last_update field to today"""
|
||||
for goal in self.browse(cr, uid, ids, vals):
|
||||
# TODO if current in vals
|
||||
vals['last_update'] = fields.date.today()
|
||||
if 'current' in vals:
|
||||
vals['last_update'] = fields.date.today()
|
||||
if goal.report_message_frequency == 'onchange':
|
||||
plan_obj = self.pool.get('gamification.goal.plan')
|
||||
plan_obj.report_progress(cr, uid, [goal.planline_id.plan_id.id], users=[goal.user_id], context=context)
|
||||
write_res = super(gamification_goal, self).write(cr, uid, ids, vals, context=context)
|
||||
return write_res
|
||||
|
||||
|
@ -342,6 +346,7 @@ class gamification_goal_plan(osv.Model):
|
|||
|
||||
_name = 'gamification.goal.plan'
|
||||
_description = 'Gamification goal plan'
|
||||
_inherit = 'mail.thread'
|
||||
|
||||
_columns = {
|
||||
'name' : fields.char('Plan Name', required=True),
|
||||
|
@ -583,9 +588,10 @@ class gamification_goal_plan(osv.Model):
|
|||
return True
|
||||
|
||||
|
||||
def report_progress(self, cr, uid, ids, context=None):
|
||||
def report_progress(self, cr, uid, ids, users=False, context=None):
|
||||
"""Post report about the progress of the goals"""
|
||||
|
||||
context = context or {}
|
||||
goal_obj = self.pool.get('gamification.goal')
|
||||
|
||||
for plan in self.browse(cr, uid, ids, context=context):
|
||||
|
@ -593,8 +599,6 @@ class gamification_goal_plan(osv.Model):
|
|||
# no report group, skipping
|
||||
continue
|
||||
|
||||
# copy of context to access more variables in templates
|
||||
template_context = dict(context)
|
||||
if plan.visibility_mode == 'board':
|
||||
# generate a shared report
|
||||
planlines_boards = []
|
||||
|
@ -625,12 +629,16 @@ class gamification_goal_plan(osv.Model):
|
|||
planlines_boards.append({'goal_type':planline.type_id.name, 'board_goals':sorted_board})
|
||||
|
||||
body_html = mako_template_env.get_template('group_progress.mako').render({'object':plan, 'planlines_boards':planlines_boards})
|
||||
self.pool.get('mail.thread').message_post(cr, uid, False,
|
||||
self.message_post(cr, uid, plan.id,
|
||||
body=body_html,
|
||||
partner_ids=[user.partner_id.id for user in plan.user_ids],
|
||||
context=context)
|
||||
#self.pool.get('email.template').send_mail(cr, uid, template_id, plan.id, context=template_context)
|
||||
|
||||
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')
|
||||
|
||||
else:
|
||||
# generate individual reports
|
||||
for user in plan.user_ids:
|
||||
|
@ -645,11 +653,16 @@ class gamification_goal_plan(osv.Model):
|
|||
'goals':goal_obj.browse(cr, uid, goal_ids, context=context)
|
||||
}
|
||||
body_html = mako_template_env.get_template('personal_progress.mako').render(variables)
|
||||
self.pool.get('mail.thread').message_post(cr, uid, False,
|
||||
|
||||
self.message_post(cr, uid, plan.id,
|
||||
body=body_html,
|
||||
partner_ids=[user.partner_id.id],
|
||||
context=context)
|
||||
#self.pool.get('email.template').send_mail(cr, uid, template_id, plan.id, context=template_context)
|
||||
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')
|
||||
return True
|
||||
|
||||
|
||||
|
|
|
@ -5,16 +5,17 @@
|
|||
</head>
|
||||
<body>
|
||||
<header>
|
||||
% if object.report_header
|
||||
${object.report_header}
|
||||
% endif
|
||||
<strong>${object.name}</strong>
|
||||
</header>
|
||||
|
||||
Below are the latest results for the plan <strong>${object.name}</strong> for the group <em>${object.report_message_group_id.name}</em>.</p>
|
||||
!${planlines_boards}!
|
||||
|
||||
<p class="oe_grey">${object.report_header or ''}</p>
|
||||
|
||||
% for planline in planlines_boards:
|
||||
<h2>${planline['goal_type']}</h2>
|
||||
|
||||
<table width="100%" border="1">
|
||||
<tr>
|
||||
<th colspan="4">${planline['goal_type']}</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>#</th>
|
||||
<th>User</th>
|
||||
|
@ -34,5 +35,8 @@
|
|||
</tr>
|
||||
% endfor
|
||||
</table>
|
||||
|
||||
<br/><br/>
|
||||
|
||||
% endfor
|
||||
</body>
|
|
@ -78,7 +78,7 @@
|
|||
</group>
|
||||
</sheet>
|
||||
<div class="oe_chatter">
|
||||
<field name="message_follower_ids" widget="mail_followers" help="Follow this goal to automatically track the events associated." groups="base.group_user"/>
|
||||
<field name="message_follower_ids" widget="mail_followers"/>
|
||||
<field name="message_ids" widget="mail_thread"/>
|
||||
</div>
|
||||
</form>
|
||||
|
|
|
@ -138,6 +138,10 @@
|
|||
</group>
|
||||
</group>
|
||||
</sheet>
|
||||
<div class="oe_chatter">
|
||||
<field name="message_follower_ids" widget="mail_followers"/>
|
||||
<field name="message_ids" widget="mail_thread"/>
|
||||
</div>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
|
Loading…
Reference in New Issue