From 12f77fa22feb8e9fe81549049ca7abb6ade1b5b6 Mon Sep 17 00:00:00 2001 From: Denis Ledoux Date: Thu, 26 Nov 2015 17:57:09 +0100 Subject: [PATCH] [FIX] mail: notify all partners of the thread As stated in the comment: ``` all notified_partner_ids of the mail.message have to be notified for the parented messages ``` Record rules are applied when browsing one2many fields. Therefore, when browsing `message.notified_partner_ids` with a user other than the SUPERUSER, the multi-company rules are applied, and a regular user could therefore not see all partners of the thread, according to which company the partners are associated with. Nevertheless, all partners of the thread have to be notified, including the ones the regular user cannot see. To reproduce the issue: - Create a second company 'Second company' - Create a third user, associated to the first company 'YourCompany' - Set the demo user as in the 'Second company' - Create a project 'test' in the first company, 'YourCompany' - In the followers of the project, add the Demo user, with as subtypes "Stages changes" only - As the third user, create a new task in this project - Change the stage of this task, as the third user [this is important] - Sign in as the demo user, and see that you cannot access your messages inbox, due to an access rights error. opw-650563 --- addons/mail/mail_message.py | 2 +- addons/mail/mail_thread.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/mail/mail_message.py b/addons/mail/mail_message.py index fbd04f21acc..ed288de1753 100644 --- a/addons/mail/mail_message.py +++ b/addons/mail/mail_message.py @@ -848,7 +848,7 @@ class mail_message(osv.Model): Call mail_notification.notify to manage the email sending """ notification_obj = self.pool.get('mail.notification') - message = self.browse(cr, uid, newid, context=context) + message = self.browse(cr, SUPERUSER_ID, newid, context=context) partners_to_notify = set([]) # all followers of the mail.message document have to be added as partners and notified if a subtype is defined (otherwise: log message) diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py index ee4eafc3edd..baef24003a4 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -1861,7 +1861,7 @@ class mail_thread(osv.AbstractModel): if msg_ids: notification_obj = self.pool.get('mail.notification') notification_obj._notify(cr, uid, msg_ids[0], partners_to_notify=partner_ids, context=context) - message = message_obj.browse(cr, uid, msg_ids[0], context=context) + message = message_obj.browse(cr, SUPERUSER_ID, msg_ids[0], context=context) if message.parent_id: partner_ids_to_parent_notify = set(partner_ids).difference(partner.id for partner in message.parent_id.notified_partner_ids) for partner_id in partner_ids_to_parent_notify: