Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

really not track inventory when inventory tracking is turned off #6429

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 4 additions & 3 deletions core/app/models/spree/stock/coordinator.rb
Expand Up @@ -27,12 +27,13 @@ def packages
# to build a package because it would be empty. Plus we avoid errors down
# the stack because it would assume the stock location has stock items
# for the given order
#
#
# Returns an array of Package instances
def build_packages(packages = Array.new)
StockLocation.active.each do |stock_location|
next unless stock_location.stock_items.where(:variant_id => inventory_units.map(&:variant_id).uniq).exists?

if Spree::Config.track_inventory_levels
next unless stock_location.stock_items.where(variant_id: inventory_units.map(&:variant_id).uniq).exists?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line is too long. [116/100]

end
packer = build_packer(stock_location, inventory_units)
packages += packer.packages
end
Expand Down
4 changes: 3 additions & 1 deletion core/app/models/spree/stock_location.rb
Expand Up @@ -77,8 +77,10 @@ def unstock(variant, quantity, originator = nil)
end

def move(variant, quantity, originator = nil)
stock_item_or_create(variant).stock_movements.create!(quantity: quantity,
if Config.track_inventory_levels
stock_item_or_create(variant).stock_movements.create!(quantity: quantity,
originator: originator)
end
end

def fill_status(variant, quantity)
Expand Down