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 @@ Received Badge + + ${object.user_id.lang} Congratulation, you have received the badge ${object.badge_id.name} ! % 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 {}