summaryrefslogtreecommitdiff
path: root/addons/test_mail/tests/test_message_compose.py
diff options
context:
space:
mode:
authorThibault Delavallée <tde@odoo.com>2018-02-15 17:24:19 +0100
committerThibault Delavallée <tde@odoo.com>2018-02-20 14:32:09 +0100
commit8a026e26c6ae25e3fdb5369a7fa3343d70fab782 (patch)
tree7aabaf433a6ebe458a3fd0c1654774d1f862988a /addons/test_mail/tests/test_message_compose.py
parent2709ffe0e2cfa5eb3801967aeb73f3a6afe80221 (diff)
[IMP] mail: update _notify API
Purpose of this commit is to allow to give additional values when rendering notification emails and to make some parameters explicit. This commit updates the _notify API. It allow to propagate a dictionary containing values given to the rendering of the notification template. This allow to have more complex templates and/or to control the rendering depending on some parameters. Indeed currently only some fixed values and values coming form the message to notify are given to the rendering context. First use will be soon when pushing notification emails not necessarily linked to documents. In this process some values will be given by the caller and not only by the message context anymore. This commit also moves some context key used to control the notification process directly in values given to the _notify method. It allows to make those parameters explicit and rely less on context. The _notify method now takes a values dictionary that may contain * add_sign: add user signature to notification email, default is True. It replaces the ``mail_notify_user_signature`` context key; * mail_auto_delete: auto delete send emails, default is True. It replaces the ``mail_auto_delete`` context key; * other values are given to the context used to render the notification template, allowing customization. It allows to remove some context switch notably in the composer. A values dictionary is computed and given to message_post and then propagated to the notification mechanism.
Diffstat (limited to 'addons/test_mail/tests/test_message_compose.py')
-rw-r--r--addons/test_mail/tests/test_message_compose.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/addons/test_mail/tests/test_message_compose.py b/addons/test_mail/tests/test_message_compose.py
index e2668cdac45..6fe72d4da6f 100644
--- a/addons/test_mail/tests/test_message_compose.py
+++ b/addons/test_mail/tests/test_message_compose.py
@@ -63,10 +63,11 @@ class TestMessagePost(BaseFunctionalTest, MockEmails, TestRecipients):
def test_post_notifications_keep_emails(self):
self.test_record.message_subscribe_users(user_ids=[self.user_admin.id])
- msg = self.test_record.sudo(self.user_employee).with_context(mail_auto_delete=False).message_post(
+ msg = self.test_record.sudo(self.user_employee).message_post(
body='Test', subject='Test',
message_type='comment', subtype='mt_comment',
- partner_ids=[self.partner_1.id, self.partner_2.id]
+ partner_ids=[self.partner_1.id, self.partner_2.id],
+ notif_values={'mail_auto_delete': False}
)
# notifications emails should not have been deleted: one for customers, one for user