diff --git a/addons/gamification/data/badge.xml b/addons/gamification/data/badge.xml index a928a342122..7af0b859048 100644 --- a/addons/gamification/data/badge.xml +++ b/addons/gamification/data/badge.xml @@ -42,19 +42,42 @@ Received Badge + New badge ${object.badge_id.name} granted + ${object.user_id.partner_id.id} ${object.user_id.lang} - Congratulation, you have received the badge ${object.badge_id.name} ! - % if object.sender_id - This badge was granted by ${object.sender_id.name}. - % endif -

- - % if object.comment -

${object.comment}

- % endif - ]]>
+ +
+

Congratulations ${object.user_id.name} !

+

You just received badge ${object.badge_id.name} !

+
+
+% if object.badge_id.description + + + + + +
+ ${user.company_id.name} + + ${object.badge_id.description} +
+% endif +
+
+

+% if object.sender_id + This badge was granted by ${object.sender_id.name}. +% endif +

+

+% if object.comment + ${object.comment} +% endif +

+
+
diff --git a/addons/gamification/models/badge.py b/addons/gamification/models/badge.py index 78ed035da4d..3ca11577c33 100644 --- a/addons/gamification/models/badge.py +++ b/addons/gamification/models/badge.py @@ -33,18 +33,15 @@ class BadgeUser(models.Model): The stats counters are incremented :param ids: list(int) of badge users that will receive the badge """ - Template = self.env['mail.template'] - template_id = self.env.ref('gamification.email_template_badge_received') + template = self.env.ref('gamification.email_template_badge_received') for badge_user in self: - # .ids would trigger the "multi mode" which returns a mapping of - # res_id to templates - template = template_id.get_email_template(badge_user.id) - body_html = Template.with_context(template._context).render_template(template.body_html, 'gamification.badge.user', badge_user.id) - badge_user.user_id.message_post( - body=body_html, - subtype='gamification.mt_badge_granted', - partner_ids=badge_user.user_id.partner_id.ids + self.env['mail.thread'].message_post_with_template( + template.id, + model=badge_user._name, + res_id=badge_user.id, + composition_mode='mass_mail', + partner_ids=badge_user.user_id.partner_id.ids, ) return True