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
This commit is contained in:
Ahmed Ejaz
2024-11-27 11:56:49 +05:00
committed by Filipe
parent 4c71ea3866
commit 16cae2dbcc

View File

@@ -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?