Files
odoo_source/addons/web_editor/models/ir_websocket.py
T
abd-msyukyu-odoo 24c3095532 [IMP] web_editor: allow collaboration for portal users
Encapsulate the `mail` ICE servers availability check in an overridable
function, since the hack does not work in a portal context, but Knowledge portal
users should be allowed to use the collaborative feature. Knowledge will
override the session check by always returning true, since mail is a dependency
of Knowledge and is therefore always installed with it.

Allow access to the edition channel for portal users.

task-3378266

X-original-commit: odoo/odoo@03e1148ac9
Part-of: odoo/odoo#128962
2023-07-28 14:53:42 +02:00

42 lines
1.6 KiB
Python

# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
import re
from odoo import models
from odoo.exceptions import AccessDenied
class IrWebsocket(models.AbstractModel):
_inherit = 'ir.websocket'
def _build_bus_channel_list(self, channels):
if self.env.uid:
# Do not alter original list.
channels = list(channels)
for channel in channels:
if isinstance(channel, str):
match = re.match(r'editor_collaboration:(\w+(?:\.\w+)*):(\w+):(\d+)', channel)
if match:
model_name = match[1]
field_name = match[2]
res_id = int(match[3])
# Verify access to the edition channel.
if self.env.user._is_public():
raise AccessDenied()
document = self.env[model_name].browse([res_id])
if not document.exists():
continue
document.check_access_rights('read')
document.check_field_access_rights('read', [field_name])
document.check_access_rule('read')
document.check_access_rights('write')
document.check_field_access_rights('write', [field_name])
document.check_access_rule('write')
channels.append((self.env.registry.db_name, 'editor_collaboration', model_name, field_name, res_id))
return super()._build_bus_channel_list(channels)