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

@@ -855,6 +855,29 @@ export class ProductMapping extends Component {
}
}
// -------------------------------------------------------------------------
// Push variants to WC
// -------------------------------------------------------------------------
async pushVariantsToWC(mapId) {
try {
this.state.loading = true;
await rpc("/web/dataset/call_kw", {
model: "woo.product.map",
method: "action_push_variants_to_wc",
args: [[mapId]],
kwargs: {},
});
this.notification.add("Variants pushed to WooCommerce successfully.", { type: "success" });
await this._refreshAll();
} catch (err) {
console.error("[ProductMapping] pushVariantsToWC error:", err);
this.notification.add(err.message || "Failed to push variants.", { type: "danger" });
} finally {
this.state.loading = false;
}
}
// -------------------------------------------------------------------------
// Bulk price sync
// -------------------------------------------------------------------------