fix: don't re-upload images for already-synced variants

Pre-fill image field only for NEW variants. Already-synced variants
get an empty image field — existing WC image is kept unless the user
actively uploads a new one in the wizard.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
gsinghpal
2026-04-01 22:06:32 -04:00
parent 39e007b42f
commit 5b76037988

View File

@@ -51,6 +51,13 @@ class WooVariantPushWizard(models.TransientModel):
variant.product_template_attribute_value_ids.mapped('name')
)
is_first = len(lines) == 0
# For already-synced variants, don't pre-fill image
# (to avoid re-uploading the same image on every sync)
# User can upload a new image if they want to change it
pre_image = False
if not already_mapped:
pre_image = variant.image_variant_1920 or variant.image_1920 or False
lines.append((0, 0, {
'product_id': variant.id,
'variant_name': variant.display_name,
@@ -59,7 +66,7 @@ class WooVariantPushWizard(models.TransientModel):
'regular_price': already_mapped.woo_regular_price if already_mapped else variant.list_price,
'sale_price': already_mapped.woo_sale_price if already_mapped else 0.0,
'cost_price': variant.standard_price,
'image': variant.image_variant_1920 or variant.image_1920 or False,
'image': pre_image,
'include': True,
'is_default': is_first,
'already_synced': bool(already_mapped),