feat: push variants button on mapped products — convert simple→variable in WC

When a mapped product is simple on WC but has variants in Odoo, a purple
"N variants" button appears in the Variants column. Clicking it:
1. Converts the WC product from simple to variable
2. Creates WC attributes and terms from Odoo attribute lines
3. Creates a WC variation for each Odoo variant with price/SKU/stock/tax/image
4. Creates woo.product.map records for each variation

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
gsinghpal
2026-04-01 17:52:37 -04:00
parent a3fa1ced16
commit a0ad52fe46
4 changed files with 212 additions and 0 deletions

View File

@@ -232,6 +232,15 @@ class WooProductSearchController(http.Controller):
'sync_inventory': m.sync_inventory,
'instance_id': m.instance_id.id if m.instance_id else False,
'instance_name': m.instance_id.name if m.instance_id else '',
'is_variation': m.is_variation,
'odoo_variant_count': len(m.product_id.product_tmpl_id.product_variant_ids) if m.product_id else 0,
'wc_is_simple': (m.woo_product_type or 'simple') == 'simple' and not m.is_variation,
'needs_variant_push': (
m.product_id
and not m.is_variation
and (m.woo_product_type or 'simple') == 'simple'
and len(m.product_id.product_tmpl_id.product_variant_ids) > 1
),
}
for m in maps
],