From 2e2aaa218e97f72cf4d97c03c23a55a1f23c77c6 Mon Sep 17 00:00:00 2001 From: Pratima Gupta Date: Tue, 6 Mar 2018 16:50:23 +0530 Subject: [PATCH] [IMP] gamification: make email templates bioutifoul Purpose of this commit is to enhance quality of templates proposed by Odoo and make them use notification layout when send by emails. Those emails are cleaner and more up to date compared to other emails. Including * calls to message_post now use the light notification layout. It is given as parameter to the message_post process; * some cleaning in templates; This commit is related to task ID 51122 (and PR #24052). --- addons/gamification/data/badge.xml | 127 ++++++++++++++++++------ addons/gamification/data/goal_base.xml | 107 +++++++------------- addons/gamification/models/challenge.py | 22 +++- addons/gamification/models/goal.py | 6 +- 4 files changed, 157 insertions(+), 105 deletions(-) diff --git a/addons/gamification/data/badge.xml b/addons/gamification/data/badge.xml index 7af0b859048..61112ffbd9a 100644 --- a/addons/gamification/data/badge.xml +++ b/addons/gamification/data/badge.xml @@ -1,3 +1,4 @@ + @@ -47,36 +48,104 @@ ${object.user_id.partner_id.id} ${object.user_id.lang} -
-

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} -
+ + +
+ + + + + + + + + + + + + + +
+ + + +
+ Your Badge
+ + ${object.badge_id.name} + +
+ ${object.user_id.company_id.name} +
+
+
+
+ + + +
+
+ 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 +

+ Thank you, +
+ % if object.sender_id and object.sender_id.signature: + ${object.sender_id.signature | safe} + % endif +
+
+
+
+
+ + + +
+ ${object.user_id.company_id.name} +
+ ${object.user_id.company_id.phone} + % if object.user_id.company_id.email + | ${object.user_id.company_id.email} + % endif + % if object.user_id.company_id.website + | + ${object.user_id.company_id.website} + + % endif +
+
-% endif - -
-

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

-

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

-
+
+ + +
+ Powered by Odoo +
+
+ + diff --git a/addons/gamification/data/goal_base.xml b/addons/gamification/data/goal_base.xml index de76683ddc0..3552be22061 100644 --- a/addons/gamification/data/goal_base.xml +++ b/addons/gamification/data/goal_base.xml @@ -8,38 +8,40 @@ Reminder for Goal Update ${object.user_id.lang} - - Reminder ${object.name} -

- -

You have not updated your progress for the goal ${object.definition_id.name} (currently reached at ${object.completeness}%) for at least ${object.remind_update_delay} days. Do not forget to do it.

- ]]>
+ +
+ Reminder ${object.name}
+You have not updated your progress for the goal ${object.definition_id.name} (currently reached at ${object.completeness}%) for at least ${object.remind_update_delay} days. Do not forget to do it. +

+Thank you, +
+ % if object.challenge_id.manager_id and object.challenge_id.manager_id.signature: + ${object.challenge_id.manager_id.signature | safe} + % endif +
Simple Challenge Report Progress - - + +
- + % set record = ctx.get('record') + % set company = record and record.company_id or user.company_id + % set challenge_lines = ctx.get('challenge_lines', []) +
% for line in challenge_lines: - = 100: - style="font-weight:bold;" - % endif - > +
- - % if object.visibility_mode == 'ranking': - - % endif +
+ % if object.visibility_mode == 'ranking': +
+ % endif +
- - -

Leaderboard

-
+

Leaderboard

+
@@ -49,7 +51,7 @@
-

Personal Performance

+
Personal Performance
@@ -67,11 +69,7 @@
${line['name']} % if line['suffix'] or line['monetary']: @@ -102,15 +100,15 @@ % for line in challenge_lines: - +
-

Top Achievers for goal ${line['name']}

+
Top Achievers for goal ${line['name']}
- % if len(line['goals'])>2: + % if len(line['goals']) == 2:
@@ -149,18 +147,16 @@
${goal['name']} -
${podiumPosition | safe}
-

- ${"%.2f" % goal['current']} - % if line['suffix'] or line['monetary']: - ${line['full_suffix']} - % endif -

+ ${"%.2f" % goal['current']} + % if line['suffix'] or line['monetary']: + ${line['full_suffix']} + % endif
@@ -187,7 +183,7 @@ (${company.currency_id.symbol}) % endif - + @@ -220,43 +216,12 @@ % endif
CompletenessCompleteness
- - - - - - - -
- - - - - -
- ${company.name}
- ${company.phone or ''} -
- % if company.email: - ${company.email}
- % endif - % if company.website: - - ${company.website} - - % endif -
-
- Powered by Odoo. -
- ]]> - - + diff --git a/addons/gamification/models/challenge.py b/addons/gamification/models/challenge.py index 140576da889..ac5286813c3 100644 --- a/addons/gamification/models/challenge.py +++ b/addons/gamification/models/challenge.py @@ -551,7 +551,12 @@ class Challenge(models.Model): challenge.message_post( body=body_html, partner_ids=challenge.mapped('user_ids.partner_id.id'), - subtype='mail.mt_comment') + subtype='mail.mt_comment', + notif_layout='mail.mail_notification_light', + notif_values={ + 'model_description': challenge._description.lower(), + } + ) if challenge.report_message_group_id: challenge.report_message_group_id.message_post( body=body_html, @@ -573,12 +578,21 @@ class Challenge(models.Model): self.env['gamification.challenge'].message_post( body=body_html, partner_ids=[(4, user.partner_id.id)], - subtype='mail.mt_comment' + subtype='mail.mt_comment', + notif_layout='mail.mail_notification_light', + notif_values={ + 'model_description': self._description.lower(), + } ) if challenge.report_message_group_id: challenge.report_message_group_id.message_post( - body=body_html, - subtype='mail.mt_comment') + body=body_html, + subtype='mail.mt_comment', + notif_layout='mail.mail_notification_light', + notif_values={ + 'model_description': self._description.lower(), + } + ) return challenge.write({'last_report_date': fields.Date.today()}) ##### Challenges ##### diff --git a/addons/gamification/models/goal.py b/addons/gamification/models/goal.py index 6cd52b2ab81..77966b00c77 100644 --- a/addons/gamification/models/goal.py +++ b/addons/gamification/models/goal.py @@ -225,7 +225,11 @@ class Goal(models.Model): self.env['mail.thread'].message_post( body=body_html, partner_ids=[ self.user_id.partner_id.id], - subtype='mail.mt_comment' + subtype='mail.mt_comment', + notif_layout='mail.mail_notification_light', + notif_values={ + 'model_description': self._description.lower(), + } ) return {'to_update': True}