Files
odoo_source/addons/mail/wizard/mail_blacklist_remove.py
T
Thibault Delavallée 1844f335d7 [IMP] mail, phone_validation: allow to log a message when (un)blacklisting
Add possibility to add a message when adding or removing a blacklist entry
for both mail and phone_validation (used for SMS). This replaces the
``action_remove_with_reason`` method.

When updating active flag this is added as a tracking note to avoid having
several messages. Indeed message is concatenated with the tracking itself
instead of adding message for tracking + a message for the log itself. When
a new record is created, a note is logged.

Task-2710804 (Mail: Clean MailThread API)
Prepares Task-2150462 (Mass Mailing: Unsubscribe flow refactoring)

Part-of: odoo/odoo#106568
2022-11-25 18:55:20 +01:00

23 lines
659 B
Python

# -*- coding: utf-8 -*-
from markupsafe import Markup
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):
if self.reason:
message = Markup('<p>%s</p>') % _("Unblock Reason: %(reason)s", reason=self.reason)
else:
message = None
return self.env['mail.blacklist']._remove(
self.email,
message=message,
)