🎉 Initial commit - Hazard Odoo 16 project
- Custom modules: hazard_shopify, hazard_inventory_report, hazard_website - Third-party modules: bi_sql_editor, query_deluxe, sql_request_abstract, l10n_mx_sat_sync_itadmin_ee - Docker setup: Odoo 16 + PostgreSQL 17 - Utility scripts: backup_hazard.sh, update_module.py - Agent configuration: .agents/AGENTS.md - Security: Enterprise modules, credentials, backups and production data excluded via .gitignore
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
|
||||
import requests
|
||||
|
||||
# Datos de conexión (basados en lo que vi en el código)
|
||||
shop_url = "hazard-mexico.myshopify.com"
|
||||
token = "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" # Tomado de mis registros previos o se asume correcto
|
||||
headers = {'X-Shopify-Access-Token': token}
|
||||
|
||||
sku = "HRS-POL-BLUKNT-M-WHT-S"
|
||||
# Primero buscamos la variante para obtener el inventory_item_id
|
||||
search_url = f"https://{shop_url}/admin/api/2024-01/products.json?handle=blue-knit-collar-white-polo" # Aproximado por el título en la imagen
|
||||
# O mejor buscamos por SKU usando el endpoint de variantes si fuera posible, pero probemos buscando el producto.
|
||||
# En realidad, como no tengo el ID de la variante a mano, voy a buscarla por SKU en el endpoint de búsqueda de productos si existe o listando.
|
||||
|
||||
print(f"--- DIAGNÓSTICO PARA SKU: {sku} ---")
|
||||
|
||||
# Intentemos obtener todas las ubicaciones primero para ver qué IDs tienen
|
||||
loc_url = f"https://{shop_url}/admin/api/2024-01/locations.json"
|
||||
resp_loc = requests.get(loc_url, headers=headers)
|
||||
locations = resp_loc.json().get('locations', [])
|
||||
print("\nUBICACIONES EN SHOPIFY:")
|
||||
for l in locations:
|
||||
print(f"ID: {l['id']} - Nombre: {l['name']}")
|
||||
|
||||
# Ahora buscamos el producto para obtener el inventory_item_id del SKU
|
||||
# Como no sé el ID del producto, voy a buscar en los primeros productos
|
||||
prod_url = f"https://{shop_url}/admin/api/2024-01/products.json?limit=50"
|
||||
resp_prod = requests.get(prod_url, headers=headers)
|
||||
products = resp_prod.json().get('products', [])
|
||||
|
||||
target_variant = None
|
||||
for p in products:
|
||||
for v in p['variants']:
|
||||
if v['sku'] == sku:
|
||||
target_variant = v
|
||||
break
|
||||
if target_variant: break
|
||||
|
||||
if target_variant:
|
||||
inv_item_id = target_variant['inventory_item_id']
|
||||
print(f"\nVARIANTE ENCONTRADA: {target_variant['id']}")
|
||||
print(f"Inventory Item ID: {inv_item_id}")
|
||||
|
||||
# Ahora pedimos los niveles de inventario
|
||||
inv_url = f"https://{shop_url}/admin/api/2024-01/inventory_levels.json?inventory_item_ids={inv_item_id}"
|
||||
resp_inv = requests.get(inv_url, headers=headers)
|
||||
levels = resp_inv.json().get('inventory_levels', [])
|
||||
|
||||
print("\nNIVELES DE INVENTARIO PARA ESTE ITEM:")
|
||||
for lvl in levels:
|
||||
print(f"Location ID: {lvl['location_id']} - Disponible: {lvl['available']}")
|
||||
else:
|
||||
print("\nNo se encontró la variante por SKU en los primeros 50 productos.")
|
||||
Reference in New Issue
Block a user