From 6212cd4d076ce6c450768fac4e6fa467eb624048 Mon Sep 17 00:00:00 2001 From: Gaetan Craig-Riou Date: Fri, 13 Jun 2025 23:25:43 +1000 Subject: [PATCH] Only add variant override permission if inventory enabled The permission shoul not be needed if inventory is disabled, but it will prevent importing into the inventory if somehow we try to import into inventory with inventory disabled. --- app/models/product_import/product_importer.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/models/product_import/product_importer.rb b/app/models/product_import/product_importer.rb index 163f8f93b4..6e54e17b59 100644 --- a/app/models/product_import/product_importer.rb +++ b/app/models/product_import/product_importer.rb @@ -193,6 +193,8 @@ module ProductImport order('is_primary_producer ASC, name'). map { |e| @editable_enterprises[e.name] = e.id } + return unless OpenFoodNetwork::FeatureToggle.enabled?(:inventory, @current_user.enterprises) + @inventory_permissions = permissions.variant_override_enterprises_per_hub end