diff options
| author | Tiffany Chang (tic) <tic@odoo.com> | 2020-02-13 12:59:34 +0000 |
|---|---|---|
| committer | Tiffany Chang (tic) <tic@odoo.com> | 2020-03-26 10:15:18 +0000 |
| commit | f9ff21a200b0c5553ba6d1314e4d9f54d3ebdd7d (patch) | |
| tree | af7ff5f3eb86d2a0ee79a23aac6397d75820f524 /addons/mail/wizard | |
| parent | 3a112c7b78d04479e7f8d27adaeb0753bdb0111c (diff) | |
[IMP] mass_mailing_(sms): Add unblacklisting button
Previously a blacklisted phone number or email address could only be
removed from their respective blacklist by going to the corresponding
blacklist view [in mass_mailing_(sms)] and manually
archiving/deactiviting the entry. All users could see that an email was
blacklisted via an fa-ban icon added next to their corresponding field
in the modules: crm, mass_mailing, mass_mailing_sms, and contacts (via
extension).
This commit adds additional fa-ban icons next to blacklisted phone
numbers and makes all instances of these icons clickable to remove them
from their corresponding blacklist using a wizard. There are several
limitations to this implementation including:
1. If both a mobile and phone number field appear within a crm lead
instance, then only the mobile field will indicate if it is blacklisted
(due to current implementation of PhoneMixin which only checks 1 phone
value against the blacklist and "sms" which returns mobile numbers first).
I.e. if a phone field value is blacklisted, but a value is typed into the
mobile field, then the phone field will never indicate that it is blacklisted.
2. If someone clicks on a unblacklisting icon after changing the
corresponding field value without clicking off the field input, then the
latest typed in value will be the one submitted for unblacklisting,
which may not actually be blacklisted (due to "is_blacklisted" flag
being a computed field and it not having a chance to re-compute to hide
the button).
3. If someone changes values in the blacklist, then someone who already
has a form open will not see icon disappear until something triggers a
re-compute of the "phone_sanitized_blacklisted" flag (this was already the
case with the icon, but now a user may try to unblacklist a value that is
already unblacklisted.)
4. Since the icon needs to be visible by everyone to indicate whether or
not a phone/email is blacklisted, users without corresponding unblacklist
permissions will be able to click on the icon. When they click on it, they
will be informed they do not have permission to unblacklist. A wizard was
determined to be the best way to implement this unblacklisting for the
following reasons:
- A "Unblacklisting Reason" is needed and will not be stored as a field.
- A field widget is unable to do this due to security settings +
inability to refresh view after unblacklisting with a
"Unblacklisting Reason" without wiping unsaved changes.
Additionally, to better align with GDPR, the corresponding form view for
the phone/email blacklist has been updated to use the same wizard to
track "Reason for unblacklisting". Unfortunately there is no
straightforward way to prevent direct "Archive" action, so users are
still able to bypass unblacklisting without being asked for a "reason
for unblacklisting".
Supports task: 2117635
Upgrade PR: odoo/upgrade#939
COM PR: odoo/odoo#45315
Diffstat (limited to 'addons/mail/wizard')
| -rw-r--r-- | addons/mail/wizard/__init__.py | 1 | ||||
| -rw-r--r-- | addons/mail/wizard/mail_blacklist_remove.py | 14 | ||||
| -rw-r--r-- | addons/mail/wizard/mail_blacklist_remove_view.xml | 19 |
3 files changed, 34 insertions, 0 deletions
diff --git a/addons/mail/wizard/__init__.py b/addons/mail/wizard/__init__.py index ee0fd32ca8a..9adf18a67af 100644 --- a/addons/mail/wizard/__init__.py +++ b/addons/mail/wizard/__init__.py @@ -2,6 +2,7 @@ # Part of Odoo. See LICENSE file for full copyright and licensing details. from . import invite +from . import mail_blacklist_remove from . import mail_compose_message from . import mail_resend_cancel from . import mail_resend_message diff --git a/addons/mail/wizard/mail_blacklist_remove.py b/addons/mail/wizard/mail_blacklist_remove.py new file mode 100644 index 00000000000..2fc6374cc3d --- /dev/null +++ b/addons/mail/wizard/mail_blacklist_remove.py @@ -0,0 +1,14 @@ +# -*- coding: utf-8 -*- + +from odoo import fields, models + + +class MailBlacklistRemove(models.TransientModel): + _name = 'mail.blacklist.remove' + _description = 'Remove email from blacklist wizard' + + email = fields.Char(name="Email", readonly=True, required=True) + reason = fields.Char(name="Reason") + + def action_unblacklist_apply(self): + return self.env['mail.blacklist'].action_remove_with_reason(self.email, self.reason) diff --git a/addons/mail/wizard/mail_blacklist_remove_view.xml b/addons/mail/wizard/mail_blacklist_remove_view.xml new file mode 100644 index 00000000000..4bc8edd4a0b --- /dev/null +++ b/addons/mail/wizard/mail_blacklist_remove_view.xml @@ -0,0 +1,19 @@ +<?xml version="1.0"?> +<odoo> + <record id="mail_blacklist_remove_view_form" model="ir.ui.view"> + <field name="name">mail.blacklist.remove.form</field> + <field name="model">mail.blacklist.remove</field> + <field name="arch" type="xml"> + <form string="mail_blacklist_removal"> + <group class="oe_title"> + <field name="email" string="Email Address"/> + <field name="reason" string="Reason"/> + </group> + <footer> + <button name="action_unblacklist_apply" string="Confirm" type="object" class="btn-primary"/> + <button string="Discard" class="btn-secondary" special="cancel"/> + </footer> + </form> + </field> + </record> +</odoo> |
