From 26009fec93db9b52d9f422df554635e9ab57d24c Mon Sep 17 00:00:00 2001 From: roen-odoo Date: Fri, 28 Jan 2022 16:02:15 +0000 Subject: [PATCH] [FIX] mail: Access error closing chat Current behavior: After creating a group chat in the discuss app you were not able to close it. Steps to reproduce: -Create a group chat with more than one user in the discuss app - Try to leave it - You get an access error opw-2736464 closes odoo/odoo#83717 X-original-commit: cc1c132ee092368e77108f327ecdc5a6d2c490a6 Signed-off-by: Nicolas Lempereur (nle) Signed-off-by: Engels Robin (roen) --- addons/mail/models/mail_channel.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/mail/models/mail_channel.py b/addons/mail/models/mail_channel.py index 3986b4d8da6..a0200762e81 100644 --- a/addons/mail/models/mail_channel.py +++ b/addons/mail/models/mail_channel.py @@ -99,7 +99,7 @@ class Channel(models.Model): @api.constrains('channel_last_seen_partner_ids', 'channel_partner_ids') def _constraint_partners_chat(self): - for ch in self.filtered(lambda ch: ch.channel_type == 'chat'): + for ch in self.sudo().filtered(lambda ch: ch.channel_type == 'chat'): if len(ch.channel_last_seen_partner_ids) > 2 or len(ch.channel_partner_ids) > 2: raise ValidationError(_("A channel of type 'chat' cannot have more than two users."))