From 7bc89a1c3478cd3ad733ebb6995f9a853a0b2ec2 Mon Sep 17 00:00:00 2001 From: miad-odoo Date: Tue, 13 Jun 2023 10:42:25 +0000 Subject: [PATCH] [FIX] base: fix traceback install demo data This commit fixes a traceback when trying to install demo data from the UI. Steps to reproduce: - create a database with website_event_track_live installed and without demo data - load demo data from the UI (settings) - odoo.exceptions.AccessError: You are not allowed to create 'Website Visitor' (website.visitor) records. There is a traceback because the installer can't create `website_visitor` records because there are no groups that have create access rights for that model. This is because xml_import used to get an environment with root privileges, that can bypass access rights, but now the environment is a parameter passed to the function and doesn't necessarily have sudo This change was introduced in 5bf1207#diff-8e4705d5ab335a8dfc2c70eeedc502a92695989f97c4f19184b49634c2c4ad55L583-R583 ; with this commit, the environment used by xml_import doesn't necessarily have sudo, so we simply make sure `load_demo` loads data with sudo. Task-3202914 closes odoo/odoo#129946 X-original-commit: 85834371e0eede05858cb2dc33412396c6e5c5bf Signed-off-by: Denis Ledoux (dle) Signed-off-by: Adrien Milis (miad) --- odoo/modules/loading.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/odoo/modules/loading.py b/odoo/modules/loading.py index 53dbc7dd48d..c3e315b446a 100644 --- a/odoo/modules/loading.py +++ b/odoo/modules/loading.py @@ -86,7 +86,7 @@ def load_demo(env, package, idref, mode): if package.data.get('demo') or package.data.get('demo_xml'): _logger.info("Module %s: loading demo", package.name) with env.cr.savepoint(flush=False): - load_data(env, idref, mode, kind='demo', package=package) + load_data(env(su=True), idref, mode, kind='demo', package=package) return True except Exception as e: # If we could not install demo data for this module