From 16cae2dbcc5c17af2df41514dcdd7987d24f4f82 Mon Sep 17 00:00:00 2001 From: Ahmed Ejaz Date: Wed, 27 Nov 2024 11:56:49 +0500 Subject: [PATCH] 12973: fix error raised in variant creation - if the sheet doesn't have the units present, then the variant is not saved due to model validation - After that, while assigning on_hand value, error is raised that the variant is not created first - Now this commit makes sure that the variant is created before implementing above logic --- app/models/product_import/entry_validator.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/models/product_import/entry_validator.rb b/app/models/product_import/entry_validator.rb index f720af4aa5..bc1c4153ce 100644 --- a/app/models/product_import/entry_validator.rb +++ b/app/models/product_import/entry_validator.rb @@ -79,10 +79,9 @@ module ProductImport if entry.attributes['on_hand'].present? new_variant.on_hand = entry.attributes['on_hand'] end + check_on_hand_nil(entry, new_variant) end - check_on_hand_nil(entry, new_variant) - if new_variant.valid? entry.product_object = new_variant entry.validates_as = 'new_variant' unless entry.errors?