Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Add missed increase_stock method
Anna Siwik7f0c5bada7bc
diff --git a/saleor/order/transitions.py b/saleor/order/transitions.pyindex 176763135a..d3bbd096d3 100644--- a/saleor/order/transitions.py+++ b/saleor/order/transitions.py@@ -1,6 +1,5 @@from saleor.order import GroupStatusfrom saleor.order.utils import add_variant_to_delivery_group-from saleor.product.models import Stockfrom saleor.product.utils import (deallocate_stock, decrease_stock, increase_stock)diff --git a/saleor/product/utils.py b/saleor/product/utils.pyindex bd15a82571..dd83772fd0 100644--- a/saleor/product/utils.py+++ b/saleor/product/utils.py@@ -383,6 +383,11 @@ def deallocate_stock(stock, quantity):stock.save(update_fields=['quantity_allocated'])+def increase_stock(stock, quantity):+ stock.quantity = F('quantity') + quantity+ stock.save(update_fields=['quantity'])++def decrease_stock(stock, quantity):stock.quantity = F('quantity') - quantitystock.quantity_allocated = F('quantity_allocated') - quantitydiff --git a/tests/test_product.py b/tests/test_product.pyindex 5c300f8896..b61e7ff7e5 100644--- a/tests/test_product.py+++ b/tests/test_product.py@@ -15,7 +15,7 @@ from saleor.product.utils import (allocate_stock, deallocate_stock, decrease_stock,get_attributes_display_map, get_availability,get_product_availability_status, get_variant_availability_status,- get_variant_picker_data)+ get_variant_picker_data, increase_stock)@pytest.fixture()@@ -57,7 +57,7 @@ def test_increase_stock(product_in_stock):stock.quantity = 100stock.quantity_allocated = 80stock.save()- models.Stock.objects.increase_stock(stock, 50)+ increase_stock(stock, 50)stock.refresh_from_db()assert stock.quantity == 150assert stock.quantity_allocated == 80