🎉 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,46 @@
|
||||
import requests
|
||||
import xmlrpc.client
|
||||
|
||||
ODOO_URL = 'http://localhost:16001'
|
||||
ODOO_DB = 'hazard_new'
|
||||
ODOO_USER = 'admin'
|
||||
ODOO_PASS = 'admin'
|
||||
|
||||
def get_shopify_credentials():
|
||||
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')
|
||||
|
||||
config_ids = models.execute_kw(ODOO_DB, uid, ODOO_PASS, 'shopify.config', 'search', [[]])
|
||||
if not config_ids:
|
||||
return None, None
|
||||
config = models.execute_kw(ODOO_DB, uid, ODOO_PASS, 'shopify.config', 'read', [config_ids[0]], {'fields': ['shop_url', 'access_token']})[0]
|
||||
return config.get('shop_url'), config.get('access_token')
|
||||
|
||||
def get_collections(shop_url, access_token):
|
||||
# Using GraphQL
|
||||
query = """
|
||||
{
|
||||
collections(first: 200, query: "title:*78*") {
|
||||
edges {
|
||||
node {
|
||||
id
|
||||
title
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
"""
|
||||
url = f"https://{shop_url}/admin/api/2023-10/graphql.json"
|
||||
headers = {
|
||||
'X-Shopify-Access-Token': access_token,
|
||||
'Content-Type': 'application/json',
|
||||
}
|
||||
resp = requests.post(url, headers=headers, json={'query': query})
|
||||
for edge in resp.json().get('data', {}).get('collections', {}).get('edges', []):
|
||||
print(f"ID: {edge['node']['id']}, Title: {edge['node']['title']}")
|
||||
|
||||
if __name__ == '__main__':
|
||||
shop_url, access_token = get_shopify_credentials()
|
||||
if shop_url:
|
||||
get_collections(shop_url, access_token)
|
||||
Reference in New Issue
Block a user