import xmlrpc.client

url = 'http://localhost:16001'
db = 'hazard_new'
username = 'admin'
password = '123'

try:
    common = xmlrpc.client.ServerProxy('{}/xmlrpc/2/common'.format(url))
    uid = common.authenticate(db, username, 'admin', {})
    
    models = xmlrpc.client.ServerProxy('{}/xmlrpc/2/object'.format(url))
    
    # 4. Verificar Ubicación de Subcontratación
    locations = models.execute_kw(db, uid, 'admin', 'stock.location', 'search_read', 
        [['|', ['name', 'ilike', 'Subcontrataci'], ['name', 'ilike', 'Subcontract']]], 
        {'fields': ['name', 'usage', 'complete_name']})
    print("\nUbicaciones de Subcontratación encontradas:")
    for loc in locations:
        print(f" - {loc['complete_name']} (Usage: {loc['usage']})")

except Exception as e:
    print("Error:", e)
