diff --git a/lib/open_food_network/products_and_inventory_report_base.rb b/lib/open_food_network/products_and_inventory_report_base.rb index dff53fdb9a..121df3221e 100644 --- a/lib/open_food_network/products_and_inventory_report_base.rb +++ b/lib/open_food_network/products_and_inventory_report_base.rb @@ -29,16 +29,18 @@ module OpenFoodNetwork end def filter(variants) - filter_to_distributor filter_to_order_cycle filter_on_hand filter_to_supplier filter_not_deleted variants + filter_on_hand filter_to_distributor filter_to_order_cycle filter_to_supplier filter_not_deleted variants end def filter_not_deleted(variants) variants.not_deleted end + # Using the `in_stock?` method allows overrides by distributors. + # It also allows the upgrade to Spree 2.0. def filter_on_hand(variants) if params[:report_type] == 'inventory' - variants.where('spree_variants.count_on_hand > 0') + variants.select(&:in_stock?) else variants end