From 9eb2cb736bbbf114351d19d5c450e674d87c468a Mon Sep 17 00:00:00 2001 From: "Anh Thao Pham (pta)" Date: Mon, 11 Dec 2023 14:13:10 +0100 Subject: [PATCH] [FIX] base: fix xml_id creation of custom groups Steps to reproduce: - Go to "Settings / Users & Companies / Groups" - Create a group (e.g. Group X) - Go to "Settings / Technical / Actions / Server Actions" - Create a server action: * Model: [any] (e.g. Contact) * Action To Do: Execute Python Code * Python Code: [any] * Security: Group X - Create contextual action - Connect with a non-admin user (i.e. Marc Demo) - Open Contacts app => An Access Error is raised: "You are not allowed to create 'Model Data' (ir.model.data) records. This operation is allowed for the following groups: - Administration/Access Rights Contact your administrator to request access if necessary." Cause: When the group is created, its external identifier is not created directly. When opening Contacts app, the list of authorized actions is evaluated. During the process, "_ensure_xml_id" is called on the groups configured on the actions to create the missing external identifiers. However, the current user (i.e. Marc Demo) has not the rights to create an external identifier. opw-3328506 closes odoo/odoo#148503 X-original-commit: 34af4c8e6b4273688881b37bfba33d457054676c Signed-off-by: Denis Ledoux (dle) Signed-off-by: Anh Thao Pham (pta) --- odoo/addons/base/models/res_users.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/odoo/addons/base/models/res_users.py b/odoo/addons/base/models/res_users.py index e097c4107ad..8ed172cbf91 100644 --- a/odoo/addons/base/models/res_users.py +++ b/odoo/addons/base/models/res_users.py @@ -230,7 +230,7 @@ class Groups(models.Model): result = self.get_external_id() missings = {group_id: f'__custom__.group_{group_id}' for group_id, ext_id in result.items() if not ext_id} if missings: - self.env['ir.model.data'].create( + self.env['ir.model.data'].sudo().create( [ { 'name': name.split('.')[1],