From 21c1e372113d7226eff4fcec7ecf7f0e159d2b15 Mon Sep 17 00:00:00 2001 From: gsinghpal Date: Wed, 1 Apr 2026 21:35:03 -0400 Subject: [PATCH] fix: save wizard images to Odoo product before passing URL to WC MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The wizard's binary image field wasn't being saved to the product.product record, so the public URL returned the default placeholder. Now saves line.image → variant.image_1920 first, then generates the URL with a cache-busting timestamp. Only includes image in WC data if the wizard line has an actual image uploaded. Co-Authored-By: Claude Opus 4.6 (1M context) --- .../wizard/woo_variant_push.py | 25 +++++++++++++------ 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/fusion-woo-odoo/fusion_woocommerce/wizard/woo_variant_push.py b/fusion-woo-odoo/fusion_woocommerce/wizard/woo_variant_push.py index 1cac3f3a..134dc5b9 100644 --- a/fusion-woo-odoo/fusion_woocommerce/wizard/woo_variant_push.py +++ b/fusion-woo-odoo/fusion_woocommerce/wizard/woo_variant_push.py @@ -171,12 +171,15 @@ class WooVariantPushWizard(models.TransientModel): if wc_tax_class: var_data['tax_class'] = wc_tax_class - # Set variant image via Odoo's public image URL - if variant.id and (variant.image_variant_1920 or variant.image_1920): + # Save wizard image to Odoo product, then pass URL to WC + if line.image: + variant.image_1920 = line.image odoo_base = inst.env['ir.config_parameter'].sudo().get_param('web.base.url', '') if odoo_base: img_name = (line.sku or variant.default_code or 'variant') + '.png' - img_url = f"{odoo_base}/web/image/product.product/{variant.id}/image_1920/{img_name}" + import time + cache_bust = int(time.time()) + img_url = f"{odoo_base}/web/image/product.product/{variant.id}/image_1920/{img_name}?t={cache_bust}" var_data['image'] = { 'src': img_url, 'name': img_name, @@ -244,14 +247,20 @@ class WooVariantPushWizard(models.TransientModel): if wc_tax_class: var_data['tax_class'] = wc_tax_class - # Set variant image via Odoo's public image URL - # WC downloads the image from this URL directly - if variant.id and (variant.image_variant_1920 or variant.image_1920): - # Build the public Odoo image URL + # Save wizard image to Odoo product, then pass URL to WC + if line.image: + # Save the image from the wizard to the actual Odoo product + variant.image_1920 = line.image + _logger.info("Saved image to Odoo product %d", variant.id) + + # Now build the public URL for WC to download odoo_base = inst.env['ir.config_parameter'].sudo().get_param('web.base.url', '') if odoo_base: img_name = (line.sku or variant.default_code or 'variant') + '.png' - img_url = f"{odoo_base}/web/image/product.product/{variant.id}/image_1920/{img_name}" + # Add timestamp to bust WC cache + import time + cache_bust = int(time.time()) + img_url = f"{odoo_base}/web/image/product.product/{variant.id}/image_1920/{img_name}?t={cache_bust}" var_data['image'] = { 'src': img_url, 'name': img_name,