[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) <nle@odoo.com>
Signed-off-by: Engels Robin (roen) <roen@odoo.com>
This commit is contained in:
roen-odoo
2022-02-01 13:38:59 +00:00
parent 7adb866ac5
commit 26009fec93
+1 -1
View File
@@ -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."))