Skip to content
Snippets Groups Projects
Commit c78eff8c authored by Benjami's avatar Benjami
Browse files

Added post-migration script

parent fe0e66a5
No related branches found
No related tags found
3 merge requests!173Release 14.0.1.1.12,!158New CE roles,!157Draft: Added coordinator and internar user role
Pipeline #35623 passed
This commit is part of merge request !158. Comments created here will be created in the context of that merge request.
{
'name': "Energy Community",
'version': '14.0.1.1.6',
'version': '14.0.1.1.11',
'depends': [
'account',
'cooperator_account_banking_mandate',
......
from odoo import SUPERUSER_ID, api
import logging
logger = logging.getLogger(__name__)
def migrate(cr, version):
logger.info("Running post migration {}".format(version))
env = api.Environment(cr, SUPERUSER_ID, {})
internal_user_role = env['res.users.role'].search([
('code', '=', 'role_internal_user')
])
role_lines = env['res.users.role.line'].search([
("role_id.code", "in", ['role_ce_admin', 'role_coordination', 'role_platform_admin'])
])
logger.info("Founded this role lines: {}".format(role_lines))
for line in role_lines:
logger.info("Processing line {line_id} from user {user}".format(
line_id=line.id, user=line.user_id.login
))
is_internal_user = self.env['res.users.role.line'].search([
("user_id.id", "=", line.user_id.id),
("role_id.id", "=", internal_user_role.id),
])
if not is_internal_user:
self.env['res.users.role.line'].sudo().create({
"user_id": line.user_id.id,
"active": line.active,
"role_id": internal_user_role.id,
})
elif is_internal_user and is_internal_user.active == False and line.active == True:
is_internal_user.write({
"active": line.active
})
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment