mirror of
https://github.com/OCA/server-backend.git
synced 2025-02-18 09:52:42 +02:00
[FIX] base_user_role : affect correct default category, when creating the related group
This commit is contained in:
21
base_user_role/migrations/12.0.2.1.0/post-migration.py
Normal file
21
base_user_role/migrations/12.0.2.1.0/post-migration.py
Normal file
@@ -0,0 +1,21 @@
|
||||
# Copyright (C) 2021 - Today: GRAP (http://www.grap.coop)
|
||||
# @author: Sylvain LE GAL (https://twitter.com/legalsylvain)
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
import logging
|
||||
from odoo import api, SUPERUSER_ID
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def _affect_group_to_category(env):
|
||||
_logger.info("Set Category 'User roles' to groups related to roles")
|
||||
roles = env["res.users.role"].search([])
|
||||
groups = roles.mapped("group_id").filtered(lambda x: not x.category_id)
|
||||
user_role_category = env.ref("base_user_role.ir_module_category_role")
|
||||
groups.write({"category_id": user_role_category.id})
|
||||
|
||||
|
||||
def migrate(cr, version):
|
||||
with api.Environment.manage():
|
||||
env = api.Environment(cr, SUPERUSER_ID, {})
|
||||
_affect_group_to_category(env)
|
||||
Reference in New Issue
Block a user