İlk versiyon: MyMach Fleet Intelligence ve yapılandırmalar
This commit is contained in:
25
addons/mymach_fleet_intelligence/fix_base_groups.py
Normal file
25
addons/mymach_fleet_intelligence/fix_base_groups.py
Normal file
@@ -0,0 +1,25 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
env = env(user=1)
|
||||
cr = env.cr
|
||||
|
||||
# 1. Reset stuck modules
|
||||
cr.execute("UPDATE ir_module_module SET state = 'installed' WHERE state IN ('to install', 'to upgrade', 'to remove');")
|
||||
|
||||
# 2. Ensure group_user exists in res_groups and ir_model_data
|
||||
cr.execute("SELECT id FROM res_groups LIMIT 1;")
|
||||
group_res = cr.fetchone()
|
||||
|
||||
if not group_res:
|
||||
cr.execute("""INSERT INTO res_groups (name, create_date, write_date) VALUES ('{"en_US": "Internal User"}', NOW(), NOW()) RETURNING id;""")
|
||||
group_id = cr.fetchone()[0]
|
||||
else:
|
||||
group_id = group_res[0]
|
||||
|
||||
cr.execute("""
|
||||
INSERT INTO ir_model_data (module, name, model, res_id)
|
||||
VALUES ('base', 'group_user', 'res.groups', %s)
|
||||
ON CONFLICT (module, name) DO UPDATE SET res_id = EXCLUDED.res_id;
|
||||
""", (group_id,))
|
||||
|
||||
cr.commit()
|
||||
print("SUCCESS: group_user XML ID restored!")
|
||||
Reference in New Issue
Block a user