From 31abe454b937aae6cc5dbe444ee86ba614f3df15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Fri, 12 Mar 2021 13:30:22 +0000 Subject: [PATCH] [FIX] website_mail_channel: improve (un)subscribe emails content and display When people (un)subscribe from mail channels through frontend interface a confirmation email is sent. However if this emails fails if may be displayed in channel chatter as there is an underlying ``mail.message``. As this message contains recipient-specific content it is better to avoid displaying it. Mail message_type is therefore set to ``user_notification`` meaning only author and recipient have access to message content. Moreover it is never displayed in any chatter. In this commit we also remove custom layouting of mail template bodies. We instead fall back on rendering template body encapsulated within a notification layout. Finally some more information for author is also added: author is set to channel creator, and email_from to formatted email of the company instead of its simple version. LINKS Task ID-2070632 (main task) Task ID-2419762 (followup task) COM PR odoo/odoo#62859 ENT PR odoo/enterprise#15172 UPG PR odoo/upgrade#2005 --- .../data/mail_template_data.xml | 180 +++--------------- .../models/mail_channel.py | 7 +- 2 files changed, 29 insertions(+), 158 deletions(-) diff --git a/addons/website_mail_channel/data/mail_template_data.xml b/addons/website_mail_channel/data/mail_template_data.xml index 52859d08aae..88fc73cb9f6 100644 --- a/addons/website_mail_channel/data/mail_template_data.xml +++ b/addons/website_mail_channel/data/mail_template_data.xml @@ -7,84 +7,18 @@ Confirm subscription to ${object.name} - - - -
- - - - - - - - - - - - - - - -
- - - -
- Your Channel
- ${object.name} -
- ${user.company_id.name} -
-
-
-
- - - -
-
- Hello,

- You have requested to be subscribed to the mailing list ${object.name}. -

- To confirm, please visit the following link: ${ctx['token_url']} -

- If this was a mistake or you did not requested this action, please ignore this message. - % if user.signature -
- ${user.signature | safe} - % endif -
-
-
-
-
- - - -
- ${user.company_id.name} -
- % if user.company_id.phone - ${user.company_id.phone} | - %endif - % if user.company_id.email - ${user.company_id.email} | - % endif - % if user.company_id.website - ${user.company_id.website} - - % endif -
-
-
- - -
- Powered by Odoo -
-
-
+
+ Hello,

+ You have requested to be subscribed to the mailing list ${object.name}. +

+ To confirm, please visit the following link: ${ctx['token_url']} +

+ If this was a mistake or you did not requested this action, please ignore this message. + % if user.signature +
+ ${user.signature | safe} + % endif +
@@ -93,84 +27,18 @@ Confirm unsubscription to ${object.name} - - - -
- - - - - - - - - - - - - - - -
- - - -
- Your Channel
- ${object.name} -
- ${user.company_id.name} -
-
-
-
- - - -
-
- Hello,

- You have requested to be unsubscribed to the mailing list ${object.name}. -

- To confirm, please visit the following link: ${ctx['token_url']}. -

- If this was a mistake or you did not requested this action, please ignore this message. - % if user.signature: -
- ${user.signature | safe} - % endif -
-
-
-
-
- - - -
- ${user.company_id.name} -
- % if user.company_id.phone - ${user.company_id.phone} | - %endif - % if user.company_id.email - ${user.company_id.email} | - % endif - % if user.company_id.website - ${user.company_id.website} - - % endif -
-
-
- - -
- Powered by Odoo -
-
-
+
+ Hello,

+ You have requested to be unsubscribed to the mailing list ${object.name}. +

+ To confirm, please visit the following link: ${ctx['token_url']}. +

+ If this was a mistake or you did not requested this action, please ignore this message. + % if user.signature: +
+ ${user.signature | safe} + % endif +
diff --git a/addons/website_mail_channel/models/mail_channel.py b/addons/website_mail_channel/models/mail_channel.py index a06fda8e0d5..c3510fc3139 100644 --- a/addons/website_mail_channel/models/mail_channel.py +++ b/addons/website_mail_channel/models/mail_channel.py @@ -45,8 +45,11 @@ class MailGroup(models.Model): force_send=True, email_values={ 'recipient_ids': [(4, partner_id)], - 'email_from': website.company_id.email, - } + 'email_from': website.company_id.email_formatted, + 'author_id': self.create_uid.partner_id.id, + 'message_type': 'user_notification', + }, + notif_layout='mail.mail_notification_light', ) return True