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

82 lines
3.7 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import xmlrpc.client
import ssl
url = "https://odoodev2.mymachconnect.com"
dbs = ['mymach-odoodev2-2026', 'mymach_odoodev2']
username = "ceren.camkaya@mymach.com.tr"
password = "cerenhanım"
ctx = ssl.create_default_context()
ctx.check_hostname = False
ctx.verify_mode = ssl.CERT_NONE
common = xmlrpc.client.ServerProxy('{}/xmlrpc/2/common'.format(url), context=ctx)
models = xmlrpc.client.ServerProxy('{}/xmlrpc/2/object'.format(url), context=ctx)
for db_name in dbs:
print(f"--- Trying DB: {db_name} ---")
try:
uid = common.authenticate(db_name, username, password, {})
if uid:
print(f"Logged in successfully to {db_name}! UID: {uid}")
# Check module status
module_ids = models.execute_kw(db_name, uid, password,
'ir.module.module', 'search_read',
[[['name', '=', 'mymach_fleet_intelligence']]],
{'fields': ['state', 'latest_version']})
if module_ids:
mod = module_ids[0]
print(f"Module found! State: {mod['state']}, Version: {mod['latest_version']}")
# Check current view XML (e.g. looking for the language selector removal)
# Let's search for a view that we modified.
# 'fleet.vehicle.form' was modified? No, 'fleet_vehicle_view_form' might have been.
# Actually, let's look for 'res.groups' view if we added it, but it's data.
# Let's look for 'mymach_fleet_intelligence.view_home_form' (which had lang removed)
# Find the view by external ID
model_data = models.execute_kw(db_name, uid, password,
'ir.model.data', 'search_read',
[[['module', '=', 'mymach_fleet_intelligence'], ['name', '=', 'view_home_form']]],
{'fields': ['res_id']})
if model_data:
view_id = model_data[0]['res_id']
view = models.execute_kw(db_name, uid, password,
'ir.ui.view', 'read',
[[view_id]],
{'fields': ['arch_db']})
if view:
arch = view[0]['arch_db']
if 'field name="lang"' in arch:
print("The view STILL HAS the language selector (Old code).")
else:
print("The view DOES NOT have language selector (New code).")
# Try to trigger an upgrade
print("Triggering module upgrade...")
models.execute_kw(db_name, uid, password,
'ir.module.module', 'button_immediate_upgrade',
[[mod['id']]])
print("Upgrade finished! Let's check the view again...")
if model_data:
view = models.execute_kw(db_name, uid, password,
'ir.ui.view', 'read',
[[view_id]],
{'fields': ['arch_db']})
if view:
arch = view[0]['arch_db']
if 'field name="lang"' in arch:
print("AFTER UPGRADE: The view STILL HAS the language selector (Old code). This means git pull failed on the server!")
else:
print("AFTER UPGRADE: The view is updated! The issue was just that it wasn't upgraded properly.")
else:
print("Module not found in this DB.")
else:
print("Login failed for this DB.")
except Exception as e:
print(f"Error for DB {db_name}: {e}")