mirror of
https://github.com/OCA/server-backend.git
synced 2025-02-18 09:52:42 +02:00
[15.0][IMP] base_user_role: action to group groups into a role
This commit is contained in:
committed by
Sébastien Alix
parent
93be01eaef
commit
3b7bbf2856
37
base_user_role/wizards/wizard_groups_into_role.py
Normal file
37
base_user_role/wizards/wizard_groups_into_role.py
Normal file
@@ -0,0 +1,37 @@
|
||||
# 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 = "wizard.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("active_ids", [])
|
||||
vals = {
|
||||
"name": self.name,
|
||||
"implied_ids": selected_group_ids,
|
||||
}
|
||||
role = self.env["res.users.role"].create(vals)
|
||||
|
||||
return {
|
||||
"type": "ir.actions.act_window",
|
||||
"res_model": "res.users.role",
|
||||
"view_mode": "form",
|
||||
"res_id": role.id,
|
||||
"target": "current",
|
||||
"context": {
|
||||
"form_view_ref": "base_user_role.view_res_users_role_form",
|
||||
},
|
||||
}
|
||||
Reference in New Issue
Block a user