summaryrefslogtreecommitdiff
path: root/addons/test_mail/tests/test_message_compose.py
diff options
context:
space:
mode:
authorThibault Delavallée <tde@odoo.com>2018-03-02 17:48:32 +0100
committerThibault Delavallée <tde@odoo.com>2018-04-03 17:11:43 +0200
commitb6d2351df45bdd049e42e828743b5dd2f1941649 (patch)
tree40fb6f3b0f515ab538fa9f5a1a1fc7754f758e1e /addons/test_mail/tests/test_message_compose.py
parent301f140cb6c872e3f4303f6ce46c626d3f04fa2f (diff)
[REF] mail: improve implementation of message subscribe
This commit refactors mail.thread message_subscribe method. It is done for two purposes. First one is to optimize performance by using the new followers computation methods introduced recently. Second purpose is to clean the API of message_subscribe to make it simpler to use. This commit splits message_subscribe in two main parts : * _message_subscribe is a private method calling the follower new subscription methods and updating the record set; * message_subscribe is a public wrapper on _message_subscribe that adds access rights checks; Simplification comes by removing message_subscribe_users that was a shortcut to message_subscribe. Having a method to subscribe partners and channels is sufficient as we would like to avoid bloating the public API of mail.thread. A force parameter is also removed from message_subscribe as this implementation detail can be induced in the computation. Various addons using the removed methods are updated in order to use the new subscription API. They have the same functional behavior. This commit has a great impact when subscribing several followers. In a more general way all code using message_post is also optimized as posting a message generally implies subscribing followers. It also improves activity use as posting a message and subscribing new followers are common process in activities.
Diffstat (limited to 'addons/test_mail/tests/test_message_compose.py')
-rw-r--r--addons/test_mail/tests/test_message_compose.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/addons/test_mail/tests/test_message_compose.py b/addons/test_mail/tests/test_message_compose.py
index 08b7760f3bd..517f0faeb1c 100644
--- a/addons/test_mail/tests/test_message_compose.py
+++ b/addons/test_mail/tests/test_message_compose.py
@@ -32,7 +32,7 @@ class TestMessagePost(BaseFunctionalTest, MockEmails, TestRecipients):
_body, _body_alt, _subject = '<p>Test Body</p>', 'Test Body', 'Test Subject'
# subscribe second employee to the group to test notifications
- self.test_record.message_subscribe_users(user_ids=[self.user_admin.id])
+ self.test_record.message_subscribe(partner_ids=[self.user_admin.partner_id.id])
msg = self.test_record.sudo(self.user_employee).message_post(
body=_body, subject=_subject,
@@ -61,7 +61,7 @@ class TestMessagePost(BaseFunctionalTest, MockEmails, TestRecipients):
@mute_logger('odoo.addons.mail.models.mail_mail')
def test_post_notifications_keep_emails(self):
- self.test_record.message_subscribe_users(user_ids=[self.user_admin.id])
+ self.test_record.message_subscribe(partner_ids=[self.user_admin.partner_id.id])
msg = self.test_record.sudo(self.user_employee).message_post(
body='Test', subject='Test',