[FIX] *: correctly search record without user
If a user is not present in the request, he is in no group at all and can not access any model, including the one available for public users. Avoid ambiguity by using sudo or add a user specifically. Part-of: odoo/odoo#125216
This commit is contained in:
@@ -8,6 +8,7 @@ from unittest.mock import patch
|
||||
from odoo.addons.mail.tests.common import mail_new_test_user
|
||||
from odoo.http import request
|
||||
from odoo.tests.common import HttpCase
|
||||
from odoo import SUPERUSER_ID
|
||||
|
||||
|
||||
@contextmanager
|
||||
@@ -19,7 +20,7 @@ def mock_auth_method_outlook(login):
|
||||
:param login: Login of the user used for the authentication
|
||||
"""
|
||||
def patched_auth_method_outlook(*args, **kwargs):
|
||||
request.update_env(user=request.env['res.users'].search([('login', '=', login)], limit=1))
|
||||
request.update_env(user=request.env['res.users'].with_user(SUPERUSER_ID).search([('login', '=', login)], limit=1))
|
||||
|
||||
with patch(
|
||||
'odoo.addons.mail_plugin.models.ir_http.IrHttp'
|
||||
|
||||
@@ -60,7 +60,7 @@ class ResUsers(models.Model):
|
||||
|
||||
@api.model
|
||||
def _get_signup_invitation_scope(self):
|
||||
current_website = self.env['website'].get_current_website()
|
||||
current_website = self.env['website'].sudo().get_current_website()
|
||||
return current_website.auth_signup_uninvited or super(ResUsers, self)._get_signup_invitation_scope()
|
||||
|
||||
@classmethod
|
||||
|
||||
@@ -975,7 +975,7 @@ class Website(models.Model):
|
||||
|
||||
# The format of `httprequest.host` is `domain:port`
|
||||
domain_name = request and request.httprequest.host or ''
|
||||
website_id = self._get_current_website_id(domain_name, fallback=fallback)
|
||||
website_id = self.sudo()._get_current_website_id(domain_name, fallback=fallback)
|
||||
return self.browse(website_id)
|
||||
|
||||
@tools.ormcache('domain_name', 'fallback')
|
||||
|
||||
@@ -183,7 +183,8 @@ class IrHttp(models.AbstractModel):
|
||||
# verify the default language set in the context is valid,
|
||||
# otherwise fallback on the company lang, english or the first
|
||||
# lang installed
|
||||
request.update_context(lang=get_lang(request.env)._get_cached('code'))
|
||||
env = request.env if request.env.uid else request.env['base'].with_user(SUPERUSER_ID).env
|
||||
request.update_context(lang=get_lang(env)._get_cached('code'))
|
||||
|
||||
@classmethod
|
||||
def _dispatch(cls, endpoint):
|
||||
|
||||
@@ -2425,7 +2425,7 @@ class IrQWeb(models.AbstractModel):
|
||||
If debug=assets, the assets will be regenerated when a file which composes them has been modified.
|
||||
Else, the assets will be generated only once and then stored in cache.
|
||||
"""
|
||||
rtl = self.env['res.lang']._lang_get_direction(self.env.context.get('lang') or self.env.user.lang) == 'rtl'
|
||||
rtl = self.env['res.lang'].sudo()._lang_get_direction(self.env.context.get('lang') or self.env.user.lang) == 'rtl'
|
||||
assets_params = self.env['ir.asset']._get_asset_params() # website_id
|
||||
debug_assets = debug and 'assets' in debug
|
||||
|
||||
|
||||
Reference in New Issue
Block a user