Files
mymach_fleet_intelligence/addons/mymach_fleet_intelligence/scratch_fix_groups.py
2026-07-23 20:00:04 +03:00

32 lines
1.7 KiB
Python

import os
def fix_files():
for root, dirs, files in os.walk('.'):
if '.git' in root or '__pycache__' in root:
continue
for file in files:
if file.endswith(('.xml', '.csv', '.py', '.js')):
filepath = os.path.join(root, file)
try:
with open(filepath, 'r', encoding='utf-8') as f:
content = f.read()
if 'group_fleet_user_v2' in content or 'group_fleet_manager_v2' in content:
# In CSV, we want to replace the exact strings with the fully qualified ones
if file == 'ir.model.access.csv':
content = content.replace('group_fleet_user_v2', 'mymach_fleet_intelligence.group_fleet_user_v2')
content = content.replace('group_fleet_manager_v2', 'mymach_fleet_intelligence.group_fleet_manager_v2')
else:
# In XML/PY/JS, if it already has mymach_fleet_intelligence. it will become mymach_fleet_intelligence.group_fleet_user_v2
content = content.replace('group_fleet_user_v2', 'group_fleet_user_v2')
content = content.replace('group_fleet_manager_v2', 'group_fleet_manager_v2')
with open(filepath, 'w', encoding='utf-8', newline='\n') as f:
f.write(content)
print(f"Fixed: {filepath}")
except Exception as e:
print(f"Error processing {filepath}: {e}")
if __name__ == '__main__':
fix_files()