[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#46606

X-original-commit: ceee2c05f8a4fc69b8ae34469ac56a055ba7b7cf
Signed-off-by: Olivier Dony (odo) <odo@openerp.com>
This commit is contained in:
Sébastien Theys
2020-02-28 17:06:10 +00:00
parent 25025a886c
commit 974736306f
+4 -1
View File
@@ -474,7 +474,10 @@ class Channel(models.Model):
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