mirror of
https://github.com/OCA/server-backend.git
synced 2025-02-18 09:52:42 +02:00
8.0 - New module 'base_user_role' to manage user roles efficiently (#608)
* [ADD] New module 'base_user_role' * [FIX] base_user_role - Review * [FIX] base_user_role - Review s/is_active/is_enabled/ * [FIX] base_user_role - Review s/is_active/is_enabled/ * [IMP] base_user_role - Translations updated (template + FR) * [FIX] base_user_role - Lint
This commit is contained in:
25
base_user_role/migrations/8.0.1.1.0/post-migration.py
Normal file
25
base_user_role/migrations/8.0.1.1.0/post-migration.py
Normal file
@@ -0,0 +1,25 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2016 ABF OSIELL <http://osiell.com>
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
from openerp import api, SUPERUSER_ID
|
||||
|
||||
|
||||
def migrate_res_users_role(env):
|
||||
"""Migrate user roles database schema.
|
||||
('res_users_role_user_rel' many2many table to 'res.users.role.line' model.
|
||||
"""
|
||||
role_line_model = env['res.users.role.line']
|
||||
query = "SELECT role_id, user_id FROM res_users_role_user_rel;"
|
||||
env.cr.execute(query)
|
||||
rows = env.cr.fetchall()
|
||||
for row in rows:
|
||||
vals = {
|
||||
'role_id': row[0],
|
||||
'user_id': row[1],
|
||||
}
|
||||
role_line_model.create(vals)
|
||||
|
||||
|
||||
def migrate(cr, version):
|
||||
env = api.Environment(cr, SUPERUSER_ID, {})
|
||||
migrate_res_users_role(env)
|
||||
Reference in New Issue
Block a user