From 3b37fa88722981a152d3e9ee0ee8e504f2761367 Mon Sep 17 00:00:00 2001 From: Luis Ramos Date: Tue, 3 Mar 2020 16:40:31 +0000 Subject: [PATCH] Move variant scoping from alias method into manifest method --- app/models/spree/shipment_decorator.rb | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/app/models/spree/shipment_decorator.rb b/app/models/spree/shipment_decorator.rb index 540a327268..b23bd7266f 100644 --- a/app/models/spree/shipment_decorator.rb +++ b/app/models/spree/shipment_decorator.rb @@ -19,18 +19,11 @@ module Spree inventory_units.group_by(&:variant).map do |variant, units| states = {} units.group_by(&:state).each { |state, iu| states[state] = iu.count } + scoper.scope(variant) OpenStruct.new(variant: variant, quantity: units.length, states: states) end end - # The shipment manifest is built by loading inventory units and variants from the DB - # These variants come unscoped - # So, we need to scope the variants just after the manifest is built - def manifest_with_scoping - manifest_without_scoping.each { |item| scoper.scope(item.variant) } - end - alias_method_chain :manifest, :scoping - def scoper @scoper ||= OpenFoodNetwork::ScopeVariantToHub.new(order.distributor) end