mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-31 21:37:16 +00:00
Fix VariantStock.overwrite_stock_levels by using stock_item.adjust_count_on_hand. This makes product_controller_decorator.bulk_update work
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user