From 294a9b7a7a9f99ba64f804f378926d1f65e7230b Mon Sep 17 00:00:00 2001 From: jlzhou Date: Tue, 5 Apr 2022 15:15:23 +0000 Subject: [PATCH] [FIX] mail: fix "you are not allowed to delete 'Listeners of a Channel' (mail.channel.partner) records" issue: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit To reproduce: 1. Start a meeting in Discuss or start a group conversation of V15, then try to leave this channel by clicking channel's x button in the page's left side `DIRECT MESSAGES` list. 2. After clicking `Leave` button in Confirmation dialog you will get Access Error prompt: Due to security restrictions, you are not allowed to delete 'Listeners of a Channel' (mail.channel.partner) records. Cause and Solution: the computed field value: Since in the middle of process, outdated.channel_id.channel_partner_ids doesn't contain current env.user, to bypass access rule restriction we need to use sudo().unlink() closes odoo/odoo#88897 X-original-commit: b3d371a4380305a2ea8fd14c30432e6ddbd9cb35 Signed-off-by: Sébastien Theys (seb) --- 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 c119460cb7c..ad2fe41c58c 100644 --- a/addons/mail/models/mail_channel.py +++ b/addons/mail/models/mail_channel.py @@ -155,7 +155,7 @@ class Channel(models.Model): if new_members: self.env['mail.channel.partner'].create(new_members) if outdated: - outdated.unlink() + outdated.sudo().unlink() def _search_channel_partner_ids(self, operator, operand): return [(