mirror of
https://github.com/OCA/server-backend.git
synced 2025-02-18 09:52:42 +02:00
[IMP] base_user_role: action to group groups into a role
This commit is contained in:
@@ -1 +1,2 @@
|
||||
from . import models
|
||||
from . import wizards
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
"views/role.xml",
|
||||
"views/user.xml",
|
||||
"views/group.xml",
|
||||
"wizards/group_groups_into_role.xml",
|
||||
],
|
||||
"installable": True,
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
|
||||
access_res_users_role,access_res_users_role,model_res_users_role,"base.group_erp_manager",1,1,1,1
|
||||
access_res_users_role_line,access_res_users_role_line,model_res_users_role_line,"base.group_erp_manager",1,1,1,1
|
||||
access_group_groups_into_role,access_group_groups_into_role,model_group_groups_into_role,,1,1,1,1
|
||||
|
||||
|
1
base_user_role/wizards/__init__.py
Normal file
1
base_user_role/wizards/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from . import group_groups_into_role
|
||||
26
base_user_role/wizards/group_groups_into_role.py
Normal file
26
base_user_role/wizards/group_groups_into_role.py
Normal file
@@ -0,0 +1,26 @@
|
||||
# Copyright 2021 Sodexis
|
||||
# License OPL-1 (See LICENSE file for full copyright and licensing details).
|
||||
|
||||
|
||||
from odoo import fields, models
|
||||
|
||||
|
||||
class GroupGroupsIntoRole(models.TransientModel):
|
||||
"""
|
||||
This wizard is used to group different groups into a role.
|
||||
"""
|
||||
|
||||
_name = "group.groups.into.role"
|
||||
_description = "Group groups into a role"
|
||||
name = fields.Char(
|
||||
required=True,
|
||||
help="Group groups into a role and specify a name for this role",
|
||||
)
|
||||
|
||||
def create_role(self):
|
||||
selected_group_ids = self.env.context.get("selected_group_ids", [])
|
||||
vals = {
|
||||
"name": self.name,
|
||||
"implied_ids": selected_group_ids,
|
||||
}
|
||||
self.env["res.users.role"].create(vals)
|
||||
39
base_user_role/wizards/group_groups_into_role.xml
Normal file
39
base_user_role/wizards/group_groups_into_role.xml
Normal file
@@ -0,0 +1,39 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<odoo>
|
||||
<record id="group_groups_into_role_wiz_view" model="ir.ui.view">
|
||||
<field name="name">group.groups.into.role.wiz.view</field>
|
||||
<field name="model">group.groups.into.role</field>
|
||||
<field name="arch" type="xml">
|
||||
<form>
|
||||
<group>
|
||||
<field name="name" />
|
||||
</group>
|
||||
<footer>
|
||||
<button
|
||||
string="Group"
|
||||
type="object"
|
||||
class="oe_highlight"
|
||||
name="create_role"
|
||||
/>
|
||||
<button string="Cancel" class="oe_link" special="cancel" />
|
||||
</footer>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
<record id="server_action_group_groups_into_role" model="ir.actions.server">
|
||||
<field name="name">Create role</field>
|
||||
<field name="model_id" ref="model_res_groups" />
|
||||
<field name="binding_model_id" ref="model_res_groups" />
|
||||
<field name="state">code</field>
|
||||
<field name="code">
|
||||
action = {
|
||||
'name': 'Specify a name for your new role',
|
||||
'type': 'ir.actions.act_window',
|
||||
'res_model': 'group.groups.into.role',
|
||||
'target': 'new',
|
||||
'views':[(env.ref('base_user_role.group_groups_into_role_wiz_view').id, 'form')],
|
||||
'context': {'selected_group_ids': [group.id for group in records]},
|
||||
}
|
||||
</field>
|
||||
</record>
|
||||
</odoo>
|
||||
Reference in New Issue
Block a user