summaryrefslogtreecommitdiff
path: root/addons
diff options
context:
space:
mode:
authorRavi Gohil <rgo@odoo.com>2015-01-21 12:23:35 +0100
committerMartin Trigaux <mat@odoo.com>2015-01-21 12:30:34 +0100
commit2acad603918c102682906e64ccb9bb3062df034c (patch)
tree3b5f0b917291fb0c8da6d211b2a1c2698f6d84b7 /addons
parent01c713aab0b9d6610c53ddc269f30c4e6a3d480b (diff)
[FIX] gamification: translatable email notification
This requires a manual update/migration for existing template. opw 619786
Diffstat (limited to 'addons')
-rw-r--r--addons/gamification/data/badge.xml2
-rw-r--r--addons/gamification/models/badge.py5
-rw-r--r--addons/gamification/models/goal.py6
3 files changed, 9 insertions, 4 deletions
diff --git a/addons/gamification/data/badge.xml b/addons/gamification/data/badge.xml
index 062e42f501a..562f720fe4d 100644
--- a/addons/gamification/data/badge.xml
+++ b/addons/gamification/data/badge.xml
@@ -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
diff --git a/addons/gamification/models/badge.py b/addons/gamification/models/badge.py
index c21595a5d0d..b28522a00d1 100644
--- a/addons/gamification/models/badge.py
+++ b/addons/gamification/models/badge.py
@@ -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,
diff --git a/addons/gamification/models/goal.py b/addons/gamification/models/goal.py
index ec6f1f9dcb8..36c824912d4 100644
--- a/addons/gamification/models/goal.py
+++ b/addons/gamification/models/goal.py
@@ -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 {}