diff options
| author | Thibault Delavallée <tde@odoo.com> | 2018-01-31 10:57:09 +0100 |
|---|---|---|
| committer | Thibault Delavallée <tde@odoo.com> | 2018-02-20 14:34:54 +0100 |
| commit | b6e621717e12c914d862f03f7546de08a5ad4e7c (patch) | |
| tree | f1c407145f69a17f034926be982bef0b3b048ce6 /addons/test_mail/tests/test_message_compose.py | |
| parent | 8a026e26c6ae25e3fdb5369a7fa3343d70fab782 (diff) | |
[IMP] mail: add method to notify recipients of content not related to a document
Mail API contains a message_post method allowing to post a message on a
document. In some cases we would like to push notifications to recipients
that are not necessarily linked to a document. For that purpose we
introduce message_notify. It is a shortcut that prepares the message and
speeds up the computation by pre-computing message values. This method
calls message_post and therefore the whole notification process. It
means no custom code for pushing inbox or email notifications is necessary.
Diffstat (limited to 'addons/test_mail/tests/test_message_compose.py')
| -rw-r--r-- | addons/test_mail/tests/test_message_compose.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/addons/test_mail/tests/test_message_compose.py b/addons/test_mail/tests/test_message_compose.py index 6fe72d4da6f..08b7760f3bd 100644 --- a/addons/test_mail/tests/test_message_compose.py +++ b/addons/test_mail/tests/test_message_compose.py @@ -213,6 +213,20 @@ class TestMessagePost(BaseFunctionalTest, MockEmails, TestRecipients): self.assertEqual(new_note.email_from, formataddr((self.user_employee.name, self.user_employee.email))) self.assertEqual(new_note.needaction_partner_ids, self.env['res.partner']) + def test_post_notify(self): + self.user_employee.write({'notification_type': 'inbox'}) + new_notification = self.env['mail.thread'].message_notify( + subject='This should be a subject', + body='<p>You have received a notification</p>', + partner_ids=[(4, self.partner_1.id), (4, self.user_employee.partner_id.id)], + ) + + self.assertEqual(new_notification.subtype_id, self.env.ref('mail.mt_note')) + self.assertEqual(new_notification.body, '<p>You have received a notification</p>') + self.assertEqual(new_notification.author_id, self.env.user.partner_id) + self.assertEqual(new_notification.email_from, formataddr((self.env.user.name, self.env.user.email))) + self.assertEqual(new_notification.needaction_partner_ids, self.partner_1 | self.user_employee.partner_id) + class TestComposer(BaseFunctionalTest, MockEmails, TestRecipients): |
