Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Applied changes from reviews
Mikail KOCAKf9b26eebd6cd
diff --git a/saleor/graphql/product/types/products.py b/saleor/graphql/product/types/products.pyindex 61ff305667..fc2830e685 100644--- a/saleor/graphql/product/types/products.py+++ b/saleor/graphql/product/types/products.py@@ -315,10 +315,8 @@ class ProductVariant(CountableDjangoObjectType, MetadataObjectType):return getattr(root, "digital_content", None)@staticmethod- def resolve_stock_quantity(root: models.ProductVariant, info):+ def resolve_stock_quantity(root: models.ProductVariant, _info):exact_quantity_available = root.quantity_available- if info.context.user.has_perm("product.manage_products"):- return exact_quantity_availablereturn min(exact_quantity_available, settings.MAX_CHECKOUT_LINE_QUANTITY)@staticmethoddiff --git a/tests/api/benchmark/test_product.py b/tests/api/benchmark/test_product.pyindex bfff3ee047..57ff1d17c9 100644--- a/tests/api/benchmark/test_product.py+++ b/tests/api/benchmark/test_product.py@@ -24,6 +24,7 @@ def test_product_details(product, api_client, count_queries):idskuname+ stockQuantityisAvailableprice {currencydiff --git a/tests/api/benchmark/test_variant.py b/tests/api/benchmark/test_variant.pyindex c7fb8c93cd..6e2e6110da 100644--- a/tests/api/benchmark/test_variant.py+++ b/tests/api/benchmark/test_variant.py@@ -24,6 +24,7 @@ def test_retrieve_variant_list(product_variant_list, api_client, count_queries):idskuname+ stockQuantityisAvailableprice {currency@@ -48,6 +49,7 @@ def test_retrieve_variant_list(product_variant_list, api_client, count_queries):edges {node {...ProductVariantFields+ stockQuantityproduct {...BasicProductFields}diff --git a/tests/api/test_product.py b/tests/api/test_product.pyindex 2bdadbc9ef..d4b4b0e9c9 100644--- a/tests/api/test_product.py+++ b/tests/api/test_product.py@@ -2391,16 +2391,15 @@ VARIANT_QUANTITY_AVAILABLE_IN_STOCK_QUERY = """"""-def test_variant_available_stock_quantity_is_not_capped_for_authorized_user(+def test_variant_available_stock_quantity_is_capped_for_authorized_user(staff_api_client, permission_manage_products, variant, settings):"""The exact quantity available in stock should be accessible for a staffuser having the permission to manage products."""- settings.MAX_CHECKOUT_LINE_QUANTITY = 50actual_stock_available = 60- expected_stock_available = actual_stock_available+ expected_stock_available = settings.MAX_CHECKOUT_LINE_QUANTITY = 50variant.quantity = actual_stock_availablevariant.quantity_allocated = 0