[FIX] mail: fix "you are not allowed to delete 'Listeners of a Channel' (mail.channel.partner) records" issue:

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) <seb@odoo.com>
This commit is contained in:
jlzhou
2022-04-15 16:45:44 +02:00
parent cb63a0bc52
commit 294a9b7a7a
+1 -1
View File
@@ -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 [(