[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) <dle@odoo.com>
Signed-off-by: Anh Thao Pham (pta) <pta@odoo.com>
This commit is contained in:
Anh Thao Pham (pta)
2024-01-10 06:12:23 +00:00
parent 51a493c6be
commit 9eb2cb736b
+1 -1
View File
@@ -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],