[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
This commit is contained in:
@@ -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'),
|
||||
})
|
||||
|
||||
@@ -71,6 +71,19 @@
|
||||
<p>You have been successfully <strong>unsubscribed</strong>!</p>
|
||||
</div>
|
||||
|
||||
<div t-if="list_ids" class="alert alert-warning">
|
||||
<p class="text-center">You are currently subscribed to those newsletters. Unsubscribing means you will not receive any news from them anymore:</p>
|
||||
<ul class="list-group mb-4">
|
||||
<t t-foreach="list_ids" t-as="list_id">
|
||||
<t t-if="list_id.is_public == True">
|
||||
<li class="list-group-item bg-transparent">
|
||||
<strong><t t-esc="list_id.name"/></strong>
|
||||
</li>
|
||||
</t>
|
||||
</t>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div t-if="show_blacklist_button" class="mb64">
|
||||
<div class="btn btn-secondary pull-right" id="button_add_blacklist" style="display:none">Blacklist Me</div>
|
||||
<div class="btn btn-secondary pull-right" id="button_remove_blacklist" style="display:none">Come Back</div>
|
||||
|
||||
Reference in New Issue
Block a user