From 42c6db1ece58f45b574e9df15919339ab4ca71d3 Mon Sep 17 00:00:00 2001 From: gla Date: Thu, 11 Oct 2018 09:44:32 +0000 Subject: [PATCH] [IMP] mass_mailing: warn when unsubscribing Current behavior before PR: When a lead or res.partner click in the 'unsubscribe' link in a mail that was sent to him via the mass mailing module (not via a particular mailing list), he is blacklisted from the whole mass mailing system. The only message he gets is "you have been successfully unsubscribed". Desired behavior after PR is merged: The user is told that he was unsubscribed, but in addition a warning is displayed telling him explicitly : - to which mailing lists he was subscribed - that he won't receive any mail from them anymore. Purpose : Warn the user that unsubscribe via a lead or res.partner mass mailing that he won't receive any mail from the mailing lists (listed in the warning) he had subscribed, if any. closes odoo/odoo#27678 --- addons/mass_mailing/controllers/main.py | 5 +++++ addons/mass_mailing/views/unsubscribe_templates.xml | 13 +++++++++++++ 2 files changed, 18 insertions(+) diff --git a/addons/mass_mailing/controllers/main.py b/addons/mass_mailing/controllers/main.py index 18b8a814dac..7d43038a3a6 100644 --- a/addons/mass_mailing/controllers/main.py +++ b/addons/mass_mailing/controllers/main.py @@ -62,6 +62,10 @@ class MassMailController(http.Controller): 'show_blacklist_button': request.env['ir.config_parameter'].sudo().get_param('mass_mailing.show_blacklist_buttons'), }) else: + opt_in_lists = request.env['mail.mass_mailing.list_contact_rel'].sudo().search([ + ('contact_id.email', '=', email), + ('opt_out', '=', False) + ]).mapped('list_id') blacklist_rec = request.env['mail.blacklist'].sudo()._add(email) self._log_blacklist_action( blacklist_rec, mailing_id, @@ -70,6 +74,7 @@ class MassMailController(http.Controller): 'email': email, 'mailing_id': mailing_id, 'res_id': res_id, + 'list_ids': opt_in_lists, 'show_blacklist_button': request.env['ir.config_parameter'].sudo().get_param( 'mass_mailing.show_blacklist_buttons'), }) diff --git a/addons/mass_mailing/views/unsubscribe_templates.xml b/addons/mass_mailing/views/unsubscribe_templates.xml index 1822ac08345..9417aeef044 100644 --- a/addons/mass_mailing/views/unsubscribe_templates.xml +++ b/addons/mass_mailing/views/unsubscribe_templates.xml @@ -71,6 +71,19 @@

You have been successfully unsubscribed!

+
+

You are currently subscribed to those newsletters. Unsubscribing means you will not receive any news from them anymore:

+ +
+