Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Don't raise InsufficientStock for track_inventory=False variants (#15475)

Carlos Ramírezcbd7310268c6
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 2a43d85186..2021a86af8 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -13,6 +13,7 @@ All notable, unreleased changes to this project will be documented in this file.
### Saleor Apps
### Other changes
+- Don't raise InsufficientStock for track_inventory=False variants #15475 by @carlosa54
# 3.19.0
diff --git a/saleor/warehouse/availability.py b/saleor/warehouse/availability.py
index 3683415bb8..f97bfc79bf 100644
--- a/saleor/warehouse/availability.py
+++ b/saleor/warehouse/availability.py
@@ -291,13 +291,16 @@ def check_stock_quantity_bulk(
if quantity > 0:
_check_quantity_limits(variant, quantity, global_quantity_limit)
+ if not variant.track_inventory:
+ continue
+
if not stocks:
insufficient_stocks.append(
InsufficientStockData(
variant=variant, available_quantity=available_quantity
)
)
- elif variant.track_inventory and quantity > available_quantity:
+ elif quantity > available_quantity:
insufficient_stocks.append(
InsufficientStockData(
variant=variant,
diff --git a/saleor/warehouse/tests/test_stock_availability.py b/saleor/warehouse/tests/test_stock_availability.py
index 4b03629065..0279bf7616 100644
--- a/saleor/warehouse/tests/test_stock_availability.py
+++ b/saleor/warehouse/tests/test_stock_availability.py
@@ -233,6 +233,17 @@ def test_check_stock_quantity_bulk(variant_with_many_stocks, channel_USD):
global_quantity_limit,
)
+ # test that it doesn't raise an error if variant.track_inventory is False
+ variant.track_inventory = False
+ variant.save(update_fields=["track_inventory"])
+ check_stock_quantity_bulk(
+ [variant],
+ country_code,
+ [available_quantity],
+ channel_USD.slug,
+ global_quantity_limit,
+ )
+
def test_check_stock_quantity_bulk_no_channel_shipping_zones(
variant_with_many_stocks, channel_USD