diff options
| author | Rémy Voet (ryv) <ryv@odoo.com> | 2019-12-18 12:01:37 +0000 |
|---|---|---|
| committer | Thibault Delavallée <tde@odoo.com> | 2020-03-12 13:54:32 +0000 |
| commit | c5e6511e8d35a206e966658325ac8dce6a097a48 (patch) | |
| tree | 821939459ad332fbab22766517e6b98e949d1e9f /addons/test_mail | |
| parent | 974f512f5f5d3b9f80a8c3fcde290e4f55cf1230 (diff) | |
[IMP] mail: ease bounce email content update based on alias security
PURPOSE
When incoming emails bounce due to alias security bounce email is quite
generic. Purpose of this task is to ease its customization and update.
SPECIFICATIONS
In order to improve the flexibility of alias, add a customizable html field
on the alias model. This html content will be send as bounce email core content
in case of bounced/unauthorized mail received for this alias,
Obviously it has no effect on 'everyone' security setting as no email will
bounce due to that issue.
If it is not set a default generic mail will be send depending on security
setting. It allows to keep void html fields when no specific bounce content
is required
In HR, an old template allowing some light customization for employee based
security option is removed as it is completely replaced by the new feature.
Also add references message-id of the mail received to the answer so that
threads are correctly set.
LINKS
Task ID 2126509
Diffstat (limited to 'addons/test_mail')
| -rw-r--r-- | addons/test_mail/tests/test_mail_gateway.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/addons/test_mail/tests/test_mail_gateway.py b/addons/test_mail/tests/test_mail_gateway.py index 698ba38264a..5a63940756b 100644 --- a/addons/test_mail/tests/test_mail_gateway.py +++ b/addons/test_mail/tests/test_mail_gateway.py @@ -235,6 +235,32 @@ class TestMailgateway(TestMailCommon): # Alias configuration # -------------------------------------------------- + @mute_logger('odoo.addons.mail.models.mail_thread', 'odoo.models.unlink', 'odoo.addons.mail.models.mail_mail') + def test_message_process_alias_config_bounced_content(self): + """ Custom bounced message for the alias => Received this custom message """ + self.alias.write({ + 'alias_contact': 'partners', + 'alias_bounced_content': '<p>What Is Dead May Never Die</p>' + }) + + # Test: custom bounced content + with self.mock_mail_gateway(): + record = self.format_and_process(MAIL_TEMPLATE, self.email_from, 'groups@test.com', subject='Should Bounce') + self.assertFalse(record, 'message_process: should have bounced') + self.assertSentEmail('"MAILER-DAEMON" <bounce.test@test.com>', ['whatever-2a840@postmaster.twitter.com'], body_content='<p>What Is Dead May Never Die</p>') + + self.alias.write({ + 'alias_contact': 'partners', + 'alias_bounced_content': '<p></br></p>' + }) + + # Test: with "empty" bounced content (simulate view, putting always '<p></br></p>' in html field) + with self.mock_mail_gateway(): + record = self.format_and_process(MAIL_TEMPLATE, self.email_from, 'groups@test.com', subject='Should Bounce') + self.assertFalse(record, 'message_process: should have bounced') + # Check if default (hardcoded) value is in the mail content + self.assertSentEmail('"MAILER-DAEMON" <bounce.test@test.com>', ['whatever-2a840@postmaster.twitter.com'], body_content='The following email sent to') + @mute_logger('odoo.addons.mail.models.mail_thread', 'odoo.models') def test_message_process_alias_user_id(self): """ Test alias ownership """ |
