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,