import xmlrpc.client

url = "http://localhost:16001"
db = "postgres"
username = "odoo"
password = "odoo"

common = xmlrpc.client.ServerProxy('{}/xmlrpc/2/common'.format(url))
uid = common.authenticate(db, username, password, {})
models = xmlrpc.client.ServerProxy('{}/xmlrpc/2/object'.format(url))

domain = [('name', '=', 'NAVY RED STRIPED POLO')]
templates = models.execute_kw(db, uid, password, 'product.template', 'search_read', [domain], {'fields': ['id', 'name', 'product_variant_ids']})

for t in templates:
    print("Template:", t['id'], t['name'])
    variants = models.execute_kw(db, uid, password, 'product.product', 'search_read', [[('id', 'in', t['product_variant_ids'])]], {'fields': ['id', 'default_code', 'shopify_variant_id']})
    for v in variants:
        print("Variant:", v)

