[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) <dle@odoo.com> Signed-off-by: Adrien Milis (miad) <miad@odoo.com>
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user