#!/usr/bin/env python3
import xmlrpc.client

ODOO_URL = 'http://localhost:16001'
ODOO_DB = 'hazard_new'
ODOO_USER = 'admin'
ODOO_PASS = 'admin'

common = xmlrpc.client.ServerProxy(f'{ODOO_URL}/xmlrpc/2/common')
uid = common.authenticate(ODOO_DB, ODOO_USER, ODOO_PASS, {})
models = xmlrpc.client.ServerProxy(f'{ODOO_URL}/xmlrpc/2/object')

module_ids = models.execute_kw(ODOO_DB, uid, ODOO_PASS, 'ir.module.module', 'search', [[('name', '=', 'hazard_shopify')]])
if module_ids:
    print(f"Actualizando modulo hazard_shopify (ID: {module_ids[0]})...")
    models.execute_kw(ODOO_DB, uid, ODOO_PASS, 'ir.module.module', 'button_immediate_upgrade', [module_ids])
    print("Actualizacion exitosa.")
else:
    print("Modulo no encontrado.")
