From 1dc3301332f2b329c2aed0a7a3a4ae6c242e4655 Mon Sep 17 00:00:00 2001 From: Nicolas Lempereur Date: Thu, 26 Dec 2019 08:18:51 +0000 Subject: [PATCH] [FIX] mass_mailing: can unsubscribe in multidomain The `unsubscribe` feature of mass mailings repose on having a link with HREF attribute `/unsubscribe_from_list` inside the mail message. When the mass mailing is sent: - relative URL are replaced by absolute URL (`/unsubscribe_from_list` is replaced by `{system parameter web.base.url}/unsubscribe_from_list`) - `{system parameter web.base.url}/unsubscribe_from_list` is replaced by the real mass mailing link containing info that will be used to unsubscribe the user. But there was an issue in the case of multiple domain, if this scenario happened: - system parameter web.base.url is http://domain1 - a user use "Test" button on a mass mailing - system parameter web.base.url becomes http://domain2 - the mass mailing is sent The unsubscribe link is broken, this is because the implementation of "Test Mailing" feature would update the mass mailing with absolute links, so if the domain change, we the `unsubscribe` link will no longer be found and replaced into the source. opw-2124890 closes #42373 closes odoo/odoo#43308 X-original-commit: c5036bcb11fef8081f005fe4bd0025aea41401a8 Signed-off-by: Nicolas Lempereur (nle) --- addons/mass_mailing/wizard/mailing_mailing_test.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/mass_mailing/wizard/mailing_mailing_test.py b/addons/mass_mailing/wizard/mailing_mailing_test.py index 5a107a8a132..c77010f9ebf 100644 --- a/addons/mass_mailing/wizard/mailing_mailing_test.py +++ b/addons/mass_mailing/wizard/mailing_mailing_test.py @@ -20,8 +20,8 @@ class TestMassMailing(models.TransientModel): mass_mail_layout = self.env.ref('mass_mailing.mass_mailing_mail_layout') for test_mail in test_emails: # Convert links in absolute URLs before the application of the shortener - mailing.write({'body_html': self.env['mail.thread']._replace_local_links(mailing.body_html)}) - body = tools.html_sanitize(mailing.body_html, sanitize_attributes=True, sanitize_style=True) + body = self.env['mail.thread']._replace_local_links(mailing.body_html) + body = tools.html_sanitize(body, sanitize_attributes=True, sanitize_style=True) mail_values = { 'email_from': mailing.email_from, 'reply_to': mailing.reply_to,