[IMP] web: save a has_group rpc at webclient startup

...when voip addon is installed.

We want to avoid predictable rpcs that are systematically done at
webclient startup. In particular, the voip service needs to know if
the user has group "base.group_user", which produces a rpc when
the service is started.

To avoid this, this commit adds the information in the page
directly. As this information is also useful at other places
(even though it's not at startup), we directly add it to the
groupCache of the user service (and we do the same for the
"base.group_system" group, which we also receive in the page).

closes odoo/odoo#139477

Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
This commit is contained in:
Aaron Bohy
2023-10-24 13:55:26 +00:00
parent e5161c86fe
commit da257e9d57
2 changed files with 5 additions and 1 deletions
+3 -1
View File
@@ -86,10 +86,12 @@ class Http(models.AbstractModel):
mods = odoo.conf.server_wide_modules or []
if request.db:
mods = list(request.registry._init_modules) + mods
is_internal_user = user.has_group('base.group_user')
session_info = {
"uid": session_uid,
"is_system": user._is_system() if session_uid else False,
"is_admin": user._is_admin() if session_uid else False,
"is_internal_user": is_internal_user,
"user_context": user_context,
"db": self.env.cr.dbname,
"user_settings": self.env['res.users.settings']._find_or_create_for_user(user)._res_users_settings_format(),
@@ -119,7 +121,7 @@ class Http(models.AbstractModel):
}
if request.session.debug:
session_info['bundle_params']['debug'] = request.session.debug
if self.env.user.has_group('base.group_user'):
if is_internal_user:
# the following is only useful in the context of a webclient bootstrapping
# but is still included in some other calls (e.g. '/web/session/authenticate')
# to avoid access errors and unnecessary information, it is only included for users
@@ -19,6 +19,8 @@ export const userService = {
kwargs: { context },
});
});
groupCache.cache["base.group_user"] = session.is_internal_user;
groupCache.cache["base.group_system"] = session.is_system;
const accessRightCache = new Cache((model, operation) => {
const url = `/web/dataset/call_kw/${model}/check_access_rights`;
return rpc(url, {