From 80d139669ac2280b8f61c784ecf49081cb022a7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Theys?= Date: Fri, 28 Feb 2020 12:25:40 +0000 Subject: [PATCH] [FIX] mail: allow to create channel with user in another company When there is no intersection between the allowed companies of the current user and the target user, the `with_user` would lead to the company check always failing. opw-2197955 closes odoo/odoo#46603 X-original-commit: ceee2c05f8a4fc69b8ae34469ac56a055ba7b7cf Signed-off-by: Olivier Dony (odo) --- addons/mail/models/mail_channel.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/addons/mail/models/mail_channel.py b/addons/mail/models/mail_channel.py index 103b8dca5a369..a4ba69f759344 100644 --- a/addons/mail/models/mail_channel.py +++ b/addons/mail/models/mail_channel.py @@ -473,7 +473,10 @@ def _channel_channel_notifications(self, partner_ids): for partner in self.env['res.partner'].browse(partner_ids): user_id = partner.user_ids and partner.user_ids[0] or False if user_id: - for channel_info in self.with_user(user_id).channel_info(): + user_channels = self.with_user(user_id).with_context( + allowed_company_ids=user_id.company_ids.ids + ) + for channel_info in user_channels.channel_info(): notifications.append([(self._cr.dbname, 'res.partner', partner.id), channel_info]) return notifications