- 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
51 lines
1.6 KiB
Python
51 lines
1.6 KiB
Python
import requests
|
|
|
|
config_script = """
|
|
config = env['shopify.config'].search([], limit=1)
|
|
token = config._ensure_access_token()
|
|
shop_domain = config.shop_url.strip().lower().replace('https://', '').split('/')[0]
|
|
product = env['product.template'].search([('name', '=', 'NAVY RED STRIPED POLO')], limit=1)
|
|
print(token, shop_domain, product.shopify_id)
|
|
"""
|
|
import subprocess
|
|
out = subprocess.check_output(['docker', 'exec', '-i', 'odoo-16-hazard-new', 'odoo', 'shell', '-d', 'hazard_new', '--no-http', '-c', '/etc/odoo/odoo.conf'], input=config_script.encode()).decode()
|
|
lines = [l for l in out.split('\n') if l and not l.startswith('2026') and not l.startswith('Odoo')]
|
|
token, shop_domain, shopify_id = lines[-1].split()
|
|
|
|
url = f"https://{shop_domain}/admin/api/2024-01/graphql.json"
|
|
headers = {
|
|
"X-Shopify-Access-Token": token,
|
|
"Content-Type": "application/json"
|
|
}
|
|
query = """
|
|
mutation productVariantsBulkCreate($productId: ID!, $variants: [ProductVariantsBulkInput!]!) {
|
|
productVariantsBulkCreate(productId: $productId, variants: $variants) {
|
|
productVariants {
|
|
id
|
|
title
|
|
sku
|
|
price
|
|
}
|
|
userErrors {
|
|
field
|
|
message
|
|
}
|
|
}
|
|
}
|
|
"""
|
|
variables = {
|
|
"productId": f"gid://shopify/Product/{shopify_id}",
|
|
"variants": [
|
|
{
|
|
"price": "100.00",
|
|
"inventoryItem": {"sku": "HRS-POL-REDSTRP-M-NVBL-XXL", "tracked": True},
|
|
"optionValues": [
|
|
{"name": "XXL", "optionName": "Talla"}
|
|
]
|
|
}
|
|
]
|
|
}
|
|
resp = requests.post(url, headers=headers, json={'query': query, 'variables': variables})
|
|
print("Status:", resp.status_code)
|
|
print("Response:", resp.json())
|