Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Fix ProductVariantUpdate preorder fields (#17100)
Tomasz Szymańskiac8fa3811174
diff --git a/saleor/graphql/product/tests/mutations/test_product_variant_update.py b/saleor/graphql/product/tests/mutations/test_product_variant_update.pyindex 35114ac500..fcea526782 100644--- a/saleor/graphql/product/tests/mutations/test_product_variant_update.py+++ b/saleor/graphql/product/tests/mutations/test_product_variant_update.py@@ -174,6 +174,7 @@ QUERY_UPDATE_VARIANT_CHANGING_FIELDS = """$externalReference: String$metadata: [MetadataInput!]$privateMetadata: [MetadataInput!]+ $preorder: PreorderSettingsInput$attributes: [AttributeValueInput!]) {productVariantUpdate(id: $id,@@ -184,7 +185,8 @@ QUERY_UPDATE_VARIANT_CHANGING_FIELDS = """externalReference: $externalReferencequantityLimitPerCustomer: $quantityLimitPerCustomer,metadata: $metadata,- privateMetadata: $privateMetadata+ preorder: $preorder,+ privateMetadata: $privateMetadata,}) {productVariant {name@@ -222,6 +224,18 @@ QUERY_UPDATE_VARIANT_CHANGING_FIELDS = """({"metadata": [{"key": "test_key1", "value": "test_value2"}]}, ["metadata"]),({"trackInventory": False}, ["track_inventory"]),({"quantityLimitPerCustomer": 5}, ["quantity_limit_per_customer"]),+ (+ {"preorder": {"globalThreshold": 11, "endDate": "2024-12-03T00:00Z"}},+ ["preorder_end_date", "preorder_global_threshold"],+ ),+ (+ {"preorder": {"globalThreshold": 10, "endDate": "2024-12-03T00:00Z"}},+ ["preorder_end_date"],+ ),+ (+ {"preorder": {"globalThreshold": 11, "endDate": "2024-12-02T00:00Z"}},+ ["preorder_global_threshold"],+ ),({"externalReference": "test-ext-ref2"}, ["external_reference"]),({"sku": 1234, "trackInventory": False, "externalReference": "test-ext-ref"},@@ -258,6 +272,9 @@ def test_update_product_variant_update_fields_when_necessary(variant.external_reference = external_referencevariant.quantity_limit_per_customer = quantity_limitvariant.track_inventory = True+ variant.is_preorder = True+ variant.preorder_global_threshold = 10+ variant.preorder_end_date = "2024-12-02T00:00Z"variant.save()variant_id = graphene.Node.to_global_id("ProductVariant", variant.pk)@@ -300,6 +317,7 @@ def test_update_product_variant_update_fields_when_necessary(["metadata", [{"key": "test_key1", "value": "test_value1"}]],["trackInventory", True],["quantityLimitPerCustomer", 9],+ ["preorder", {"globalThreshold": 10, "endDate": "2024-12-02T00:00Z"}],["externalReference", "test-ext-ref"],],)@@ -326,6 +344,9 @@ def test_update_product_variant_skip_updating_fields_when_unchanged(product.default_variant = variantproduct.save(update_fields=["default_variant"])variant.name = variant_name+ variant.is_preorder = True+ variant.preorder_global_threshold = 10+ variant.preorder_end_date = "2024-12-02T00:00Z"variant.metadata = {"test_key1": "test_value1"}variant.private_metadata = {"private_key1": "private_value_1"}variant.external_reference = external_referencediff --git a/saleor/product/models.py b/saleor/product/models.pyindex 08f709eda2..ce288ded38 100644--- a/saleor/product/models.py+++ b/saleor/product/models.py@@ -463,6 +463,8 @@ class ProductVariant(SortableModel, ModelWithMetadata, ModelWithExternalReferenc"external_reference","metadata","private_metadata",+ "preorder_end_date",+ "preorder_global_threshold",]def serialize_for_comparison(self):