From 27955c8c41c91c12a9cd2fa671ec877f2199f254 Mon Sep 17 00:00:00 2001 From: gsinghpal Date: Wed, 1 Apr 2026 21:37:39 -0400 Subject: [PATCH] fix: force commit image save and add debug logging for variant images Image wasn't persisting because transient model write was in the same transaction. Added cr.commit() after saving image to ensure it's available when WC downloads it. Added size/type logging to trace image data flow. Co-Authored-By: Claude Opus 4.6 (1M context) --- .../wizard/woo_variant_push.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 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 134dc5b9..39046db9 100644 --- a/fusion-woo-odoo/fusion_woocommerce/wizard/woo_variant_push.py +++ b/fusion-woo-odoo/fusion_woocommerce/wizard/woo_variant_push.py @@ -172,8 +172,9 @@ class WooVariantPushWizard(models.TransientModel): var_data['tax_class'] = wc_tax_class # Save wizard image to Odoo product, then pass URL to WC - if line.image: - variant.image_1920 = line.image + if line.image and len(line.image) > 100: + variant.sudo().write({'image_1920': line.image}) + self.env.cr.commit() 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' @@ -249,9 +250,16 @@ class WooVariantPushWizard(models.TransientModel): # Save wizard image to Odoo product, then pass URL to WC if line.image: + img_data = line.image + img_size = len(img_data) if img_data else 0 + _logger.info("Variant %d image data: type=%s size=%d", variant.id, type(img_data).__name__, img_size) # 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) + if img_size > 100: # Skip tiny placeholders + variant.sudo().write({'image_1920': img_data}) + self.env.cr.commit() # Force commit so the image is available for download + _logger.info("Saved image to Odoo product %d (%d bytes)", variant.id, img_size) + else: + _logger.warning("Skipping tiny image for variant %d (%d bytes)", variant.id, img_size) # Now build the public URL for WC to download odoo_base = inst.env['ir.config_parameter'].sudo().get_param('web.base.url', '')