[FIX] gamification: translatable email notification

This requires a manual update/migration for existing template. opw 619786
This commit is contained in:
Ravi Gohil
2015-01-21 12:30:34 +01:00
committed by Martin Trigaux
parent 01c713aab0
commit 2acad60391
3 changed files with 9 additions and 4 deletions
+2
View File
@@ -44,6 +44,8 @@
<record id="email_template_badge_received" model="mail.template">
<field name="name">Received Badge</field>
<field name="model_id" ref="gamification.model_gamification_badge_user"/>
<field name="lang">${object.user_id.lang}</field>
<field name="body_html"><![CDATA[
<p>Congratulation, you have received the badge <strong>${object.badge_id.name}</strong> !
% if object.sender_id
+3 -2
View File
@@ -61,9 +61,10 @@ class gamification_badge_user(osv.Model):
res = True
temp_obj = self.pool.get('mail.template')
user_obj = self.pool.get('res.users')
template_id = self.pool['ir.model.data'].get_object(cr, uid, 'gamification', 'email_template_badge_received', context)
template_id = self.pool['ir.model.data'].get_object_reference(cr, uid, 'gamification', 'email_template_badge_received')[1]
for badge_user in self.browse(cr, uid, ids, context=context):
body_html = temp_obj.render_template(cr, uid, template_id.body_html, 'gamification.badge.user', badge_user.id, context=context)
template = temp_obj.get_email_template(cr, uid, template_id, badge_user.id, context=context)
body_html = temp_obj.render_template(cr, uid, template.body_html, 'gamification.badge.user', badge_user.id, context=template._context)
res = user_obj.message_post(
cr, uid, badge_user.user_id.id,
body=body_html,
+4 -2
View File
@@ -257,14 +257,16 @@ class gamification_goal(osv.Model):
:return: data to write on the goal object
"""
temp_obj = self.pool['mail.template']
if goal.remind_update_delay and goal.last_update:
delta_max = timedelta(days=goal.remind_update_delay)
last_update = datetime.strptime(goal.last_update, DF).date()
if date.today() - last_update > delta_max:
# generate a remind report
temp_obj = self.pool.get('mail.template')
template_id = self.pool['ir.model.data'].get_object(cr, uid, 'gamification', 'email_template_goal_reminder', context)
body_html = temp_obj.render_template(cr, uid, template_id.body_html, 'gamification.goal', goal.id, context=context)
template_id = self.pool['ir.model.data'].get_object_reference(cr, uid, 'gamification', 'email_template_goal_reminder')[0]
template = temp_obj.get_email_template(cr, uid, template_id, goal.id, context=context)
body_html = temp_obj.render_template(cr, uid, template.body_html, 'gamification.goal', goal.id, context=template._context)
self.pool['mail.thread'].message_post(cr, uid, 0, body=body_html, partner_ids=[goal.user_id.partner_id.id], context=context, subtype='mail.mt_comment')
return {'to_update': True}
return {}