From 2df06fef46d358db9c74c00da5684110073c494c Mon Sep 17 00:00:00 2001 From: Yannick Tivisse <yti@odoo.com> Date: Tue, 4 May 2021 11:42:28 +0200 Subject: [PATCH] [FIX] ir_demo.py: Force admin access to load demo data Only admin users should be able to load demo data, if needed. This is only possible from the settings dashboard, and thus, the method could be decorated. See: c002e2eb379e8a3db90b45269f8ff2b7e246c8b2 --- odoo/addons/base/models/ir_demo.py | 5 +++++ odoo/addons/base/models/ir_module.py | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/odoo/addons/base/models/ir_demo.py b/odoo/addons/base/models/ir_demo.py index 6c8775aee5e9..e7ee63874efd 100644 --- a/odoo/addons/base/models/ir_demo.py +++ b/odoo/addons/base/models/ir_demo.py @@ -1,5 +1,9 @@ +# -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. + from odoo import models from odoo.modules.loading import force_demo +from odoo.addons.base.models.ir_module import assert_log_admin_access class IrDemo(models.TransientModel): @@ -7,6 +11,7 @@ class IrDemo(models.TransientModel): _name = 'ir.demo' _description = 'Demo' + @assert_log_admin_access def install_demo(self): force_demo(self.env.cr) return { diff --git a/odoo/addons/base/models/ir_module.py b/odoo/addons/base/models/ir_module.py index 7fc213bf1bb7..52f9e2c63a6f 100644 --- a/odoo/addons/base/models/ir_module.py +++ b/odoo/addons/base/models/ir_module.py @@ -65,7 +65,7 @@ def assert_log_admin_access(method): def check_and_log(method, self, *args, **kwargs): user = self.env.user origin = request.httprequest.remote_addr if request else 'n/a' - log_data = (method.__name__, self.sudo().mapped('name'), user.login, user.id, origin) + log_data = (method.__name__, self.sudo().mapped('display_name'), user.login, user.id, origin) if not self.env.is_admin(): _logger.warning('DENY access to module.%s on %s to user %s ID #%s via %s', *log_data) raise AccessDenied() -- GitLab