From ba8aa110c2eb441342c6ebe839bb83eedaa0bd84 Mon Sep 17 00:00:00 2001 From: luisramos0 Date: Fri, 23 Nov 2018 12:03:14 +0000 Subject: [PATCH] Fix VariantStock.overwrite_stock_levels by using stock_item.adjust_count_on_hand. This makes product_controller_decorator.bulk_update work --- app/models/concerns/variant_stock.rb | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/app/models/concerns/variant_stock.rb b/app/models/concerns/variant_stock.rb index d043db7d1a..75fc16151a 100644 --- a/app/models/concerns/variant_stock.rb +++ b/app/models/concerns/variant_stock.rb @@ -126,11 +126,8 @@ module VariantStock end # Backwards compatible setting of stock levels in Spree 2.0. - # It would be better to use `Spree::StockItem.adjust_count_on_hand` which - # takes a value to add to the current stock level and uses proper locking. - # But this should work the same as in Spree 1.3. def overwrite_stock_levels(new_level) - stock_item.__send__(:count_on_hand=, new_level) + stock_item.adjust_count_on_hand(new_level - stock_item.count_on_hand) end # There shouldn't be any other stock items, because we should