Skip to content

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

Rename ProductType type field to kind field

IKarbowiak49510dab4324
diff --git a/saleor/core/tests/test_core.py b/saleor/core/tests/test_core.py
index 24bf8efc72..b690977348 100644
--- a/saleor/core/tests/test_core.py
+++ b/saleor/core/tests/test_core.py
@@ -294,7 +294,7 @@ def test_generate_unique_slug_with_slugable_field(
ProductType.objects.create(
name=name,
slug=slug,
- type=ProductTypeKind.NORMAL,
+ kind=ProductTypeKind.NORMAL,
)
instance, _ = ProductType.objects.get_or_create(name=product_name)
diff --git a/saleor/graphql/attribute/tests/deprecated/test_attributes.py b/saleor/graphql/attribute/tests/deprecated/test_attributes.py
index 5c982a8ae8..447ddefc17 100644
--- a/saleor/graphql/attribute/tests/deprecated/test_attributes.py
+++ b/saleor/graphql/attribute/tests/deprecated/test_attributes.py
@@ -43,7 +43,7 @@ def test_attributes_query_with_filter(
name="Other type",
has_variants=True,
is_shipping_required=True,
- type=ProductTypeKind.NORMAL,
+ kind=ProductTypeKind.NORMAL,
)
other_product_type.product_attributes.add(other_attribute)
diff --git a/saleor/graphql/attribute/tests/queries/test_attribute_filter.py b/saleor/graphql/attribute/tests/queries/test_attribute_filter.py
index e35bbf3b61..00f9672e58 100644
--- a/saleor/graphql/attribute/tests/queries/test_attribute_filter.py
+++ b/saleor/graphql/attribute/tests/queries/test_attribute_filter.py
@@ -135,7 +135,7 @@ def test_filter_attributes_in_category_invalid_category_id(
product_type = ProductType.objects.create(
name="Default Type 2",
slug="default-type-2",
- type=ProductTypeKind.NORMAL,
+ kind=ProductTypeKind.NORMAL,
has_variants=True,
is_shipping_required=True,
)
@@ -177,7 +177,7 @@ def test_filter_attributes_in_category_object_with_given_id_does_not_exist(
product_type = ProductType.objects.create(
name="Default Type 2",
slug="default-type-2",
- type=ProductTypeKind.NORMAL,
+ kind=ProductTypeKind.NORMAL,
has_variants=True,
is_shipping_required=True,
)
@@ -214,7 +214,7 @@ def test_filter_attributes_in_category_not_visible_in_listings_by_customer(
product_type = ProductType.objects.create(
name="Default Type 2",
slug="default-type-2",
- type=ProductTypeKind.NORMAL,
+ kind=ProductTypeKind.NORMAL,
has_variants=True,
is_shipping_required=True,
)
@@ -264,7 +264,7 @@ def test_filter_attributes_in_category_not_visible_in_listings_by_staff_with_per
product_type = ProductType.objects.create(
name="Default Type 2",
slug="default-type-2",
- type=ProductTypeKind.NORMAL,
+ kind=ProductTypeKind.NORMAL,
has_variants=True,
is_shipping_required=True,
)
@@ -308,7 +308,7 @@ def test_filter_attributes_in_category_not_in_listings_by_staff_without_manage_p
product_type = ProductType.objects.create(
name="Default Type 2",
slug="default-type-2",
- type=ProductTypeKind.NORMAL,
+ kind=ProductTypeKind.NORMAL,
has_variants=True,
is_shipping_required=True,
)
@@ -355,7 +355,7 @@ def test_filter_attributes_in_category_not_visible_in_listings_by_app_with_perm(
product_type = ProductType.objects.create(
name="Default Type 2",
slug="default-type-2",
- type=ProductTypeKind.NORMAL,
+ kind=ProductTypeKind.NORMAL,
has_variants=True,
is_shipping_required=True,
)
@@ -399,7 +399,7 @@ def test_filter_attributes_in_category_not_in_listings_by_app_without_manage_pro
product_type = ProductType.objects.create(
name="Default Type 2",
slug="default-type-2",
- type=ProductTypeKind.NORMAL,
+ kind=ProductTypeKind.NORMAL,
has_variants=True,
is_shipping_required=True,
)
@@ -440,7 +440,7 @@ def test_filter_attributes_in_category_not_published_by_customer(
product_type = ProductType.objects.create(
name="Default Type 2",
slug="default-type-2",
- type=ProductTypeKind.NORMAL,
+ kind=ProductTypeKind.NORMAL,
has_variants=True,
is_shipping_required=True,
)
@@ -490,7 +490,7 @@ def test_filter_attributes_in_category_not_published_by_staff_with_perm(
product_type = ProductType.objects.create(
name="Default Type 2",
slug="default-type-2",
- type=ProductTypeKind.NORMAL,
+ kind=ProductTypeKind.NORMAL,
has_variants=True,
is_shipping_required=True,
)
@@ -534,7 +534,7 @@ def test_filter_attributes_in_category_not_published_by_staff_without_manage_pro
product_type = ProductType.objects.create(
name="Default Type 2",
slug="default-type-2",
- type=ProductTypeKind.NORMAL,
+ kind=ProductTypeKind.NORMAL,
has_variants=True,
is_shipping_required=True,
)
@@ -581,7 +581,7 @@ def test_filter_attributes_in_category_not_published_by_app_with_perm(
product_type = ProductType.objects.create(
name="Default Type 2",
slug="default-type-2",
- type=ProductTypeKind.NORMAL,
+ kind=ProductTypeKind.NORMAL,
has_variants=True,
is_shipping_required=True,
)
@@ -625,7 +625,7 @@ def test_filter_attributes_in_category_not_published_by_app_without_manage_produ
product_type = ProductType.objects.create(
name="Default Type 2",
slug="default-type-2",
- type=ProductTypeKind.NORMAL,
+ kind=ProductTypeKind.NORMAL,
has_variants=True,
is_shipping_required=True,
)
@@ -666,7 +666,7 @@ def test_filter_attributes_in_collection_invalid_category_id(
product_type = ProductType.objects.create(
name="Default Type 2",
slug="default-type-2",
- type=ProductTypeKind.NORMAL,
+ kind=ProductTypeKind.NORMAL,
has_variants=True,
is_shipping_required=True,
)
@@ -711,7 +711,7 @@ def test_filter_attributes_in_collection_object_with_given_id_does_not_exist(
product_type = ProductType.objects.create(
name="Default Type 2",
slug="default-type-2",
- type=ProductTypeKind.NORMAL,
+ kind=ProductTypeKind.NORMAL,
has_variants=True,
is_shipping_required=True,
)
@@ -751,7 +751,7 @@ def test_filter_attributes_in_collection_not_visible_in_listings_by_customer(
product_type = ProductType.objects.create(
name="Default Type 2",
slug="default-type-2",
- type=ProductTypeKind.NORMAL,
+ kind=ProductTypeKind.NORMAL,
has_variants=True,
is_shipping_required=True,
)
@@ -794,7 +794,7 @@ def test_filter_in_collection_not_published_by_customer(
product_type = ProductType.objects.create(
name="Default Type 2",
slug="default-type-2",
- type=ProductTypeKind.NORMAL,
+ kind=ProductTypeKind.NORMAL,
has_variants=True,
is_shipping_required=True,
)
@@ -847,7 +847,7 @@ def test_filter_in_collection_not_published_by_staff_with_perm(
product_type = ProductType.objects.create(
name="Default Type 2",
slug="default-type-2",
- type=ProductTypeKind.NORMAL,
+ kind=ProductTypeKind.NORMAL,
has_variants=True,
is_shipping_required=True,
)
@@ -894,7 +894,7 @@ def test_filter_in_collection_not_published_by_staff_without_manage_products(
product_type = ProductType.objects.create(
name="Default Type 2",
slug="default-type-2",
- type=ProductTypeKind.NORMAL,
+ kind=ProductTypeKind.NORMAL,
has_variants=True,
is_shipping_required=True,
)
@@ -944,7 +944,7 @@ def test_filter_in_collection_not_published_by_app_with_perm(
product_type = ProductType.objects.create(
name="Default Type 2",
slug="default-type-2",
- type=ProductTypeKind.NORMAL,
+ kind=ProductTypeKind.NORMAL,
has_variants=True,
is_shipping_required=True,
)
@@ -991,7 +991,7 @@ def test_filter_in_collection_not_published_by_app_without_manage_products(
product_type = ProductType.objects.create(
name="Default Type 2",
slug="default-type-2",
- type=ProductTypeKind.NORMAL,
+ kind=ProductTypeKind.NORMAL,
has_variants=True,
is_shipping_required=True,
)
diff --git a/saleor/graphql/attribute/tests/queries/test_attribute_filtering_with_channels.py b/saleor/graphql/attribute/tests/queries/test_attribute_filtering_with_channels.py
index 273d294bd6..5be15bc37a 100644
--- a/saleor/graphql/attribute/tests/queries/test_attribute_filtering_with_channels.py
+++ b/saleor/graphql/attribute/tests/queries/test_attribute_filtering_with_channels.py
@@ -56,7 +56,7 @@ def attributes_for_filtering_with_channels(
product_type = ProductType.objects.create(
name="My Product Type",
- type=ProductTypeKind.NORMAL,
+ kind=ProductTypeKind.NORMAL,
)
product = Product.objects.create(
name="Test product",
diff --git a/saleor/graphql/attribute/tests/queries/test_attribute_pagination.py b/saleor/graphql/attribute/tests/queries/test_attribute_pagination.py
index 0c568b20c5..118dbefa70 100644
--- a/saleor/graphql/attribute/tests/queries/test_attribute_pagination.py
+++ b/saleor/graphql/attribute/tests/queries/test_attribute_pagination.py
@@ -60,7 +60,7 @@ def attributes_for_pagination(collection, category, channel_USD):
product_type = ProductType.objects.create(
name="My Product Type",
- type=ProductTypeKind.NORMAL,
+ kind=ProductTypeKind.NORMAL,
)
product = Product.objects.create(
name="Test product",
diff --git a/saleor/graphql/attribute/tests/queries/test_attribute_query.py b/saleor/graphql/attribute/tests/queries/test_attribute_query.py
index 67b6b93721..8ffc1e1095 100644
--- a/saleor/graphql/attribute/tests/queries/test_attribute_query.py
+++ b/saleor/graphql/attribute/tests/queries/test_attribute_query.py
@@ -536,7 +536,7 @@ def test_attributes_in_collection_query(
name="Other type",
has_variants=True,
is_shipping_required=True,
- type=ProductTypeKind.NORMAL,
+ kind=ProductTypeKind.NORMAL,
)
other_product_type.product_attributes.add(other_attribute)
other_product = Product.objects.create(
diff --git a/saleor/graphql/product/mutations/products.py b/saleor/graphql/product/mutations/products.py
index 472148703e..e0de0c2e16 100644
--- a/saleor/graphql/product/mutations/products.py
+++ b/saleor/graphql/product/mutations/products.py
@@ -1082,7 +1082,7 @@ class ProductVariantDelete(ModelDeleteMutation):
class ProductTypeInput(graphene.InputObjectType):
name = graphene.String(description="Name of the product type.")
slug = graphene.String(description="Product type slug.")
- type = ProductTypeKindEnum(description="The product type type.")
+ kind = ProductTypeKindEnum(description="The product type kind.")
has_variants = graphene.Boolean(
description=(
"Determines if product of this type has multiple variants. This option "
diff --git a/saleor/graphql/product/tests/test_attributes.py b/saleor/graphql/product/tests/test_attributes.py
index cb08e4c61b..c21d2088ee 100644
--- a/saleor/graphql/product/tests/test_attributes.py
+++ b/saleor/graphql/product/tests/test_attributes.py
@@ -298,7 +298,7 @@ def test_assign_attributes_to_product_type(
product_type = ProductType.objects.create(
name="Default Type",
has_variants=True,
- type=ProductTypeKind.NORMAL,
+ kind=ProductTypeKind.NORMAL,
)
product_type_global_id = graphene.Node.to_global_id("ProductType", product_type.pk)
@@ -355,7 +355,7 @@ def test_assign_non_existing_attributes_to_product_type(
product_type_attribute_list,
):
product_type = ProductType.objects.create(
- name="Default Type", has_variants=True, type=ProductTypeKind.NORMAL
+ name="Default Type", has_variants=True, kind=ProductTypeKind.NORMAL
)
product_type_global_id = graphene.Node.to_global_id("ProductType", product_type.pk)
@@ -465,7 +465,7 @@ def test_assign_attribute_to_product_type_having_already_that_attribute(
"""The assignAttribute mutation should raise an error when trying
to add an attribute already contained in the product type."""
- product_type = ProductType.objects.create(name="Type", type=ProductTypeKind.NORMAL)
+ product_type = ProductType.objects.create(name="Type", kind=ProductTypeKind.NORMAL)
attribute = color_attribute_without_values
staff_api_client.user.user_permissions.add(
permission_manage_product_types_and_attributes
@@ -545,7 +545,7 @@ def test_assign_attribute_to_product_type_multiple_errors_returned(
tag_page_attribute,
):
# given
- product_type = ProductType.objects.create(name="Type", type=ProductTypeKind.NORMAL)
+ product_type = ProductType.objects.create(name="Type", kind=ProductTypeKind.NORMAL)
staff_api_client.user.user_permissions.add(
permission_manage_product_types_and_attributes
)
@@ -632,7 +632,7 @@ def test_unassign_attributes_from_product_type(
permission_manage_product_types_and_attributes,
product_type_attribute_list,
):
- product_type = ProductType.objects.create(name="Type", type=ProductTypeKind.NORMAL)
+ product_type = ProductType.objects.create(name="Type", kind=ProductTypeKind.NORMAL)
product_type_global_id = graphene.Node.to_global_id("ProductType", product_type.pk)
variant_attribute, *product_attributes = product_type_attribute_list
@@ -682,7 +682,7 @@ def test_unassign_attributes_not_in_product_type(
permission_manage_product_types_and_attributes
)
- product_type = ProductType.objects.create(name="Type", type=ProductTypeKind.NORMAL)
+ product_type = ProductType.objects.create(name="Type", kind=ProductTypeKind.NORMAL)
product_type_global_id = graphene.Node.to_global_id("ProductType", product_type.pk)
query = PRODUCT_UNASSIGN_ATTR_QUERY
@@ -806,7 +806,7 @@ def test_sort_attributes_within_product_type_invalid_id(
"""Try to reorder an attribute not associated to the given product type."""
product_type = ProductType.objects.create(
- name="Dummy Type", type=ProductTypeKind.NORMAL
+ name="Dummy Type", kind=ProductTypeKind.NORMAL
)
product_type_id = graphene.Node.to_global_id("ProductType", product_type.id)
@@ -859,7 +859,7 @@ def test_sort_attributes_within_product_type(
)
product_type = ProductType.objects.create(
- name="Dummy Type", type=ProductTypeKind.NORMAL
+ name="Dummy Type", kind=ProductTypeKind.NORMAL
)
product_type_id = graphene.Node.to_global_id("ProductType", product_type.id)
m2m_attributes = getattr(product_type, relation_field)
diff --git a/saleor/graphql/product/tests/test_bulk_delete.py b/saleor/graphql/product/tests/test_bulk_delete.py
index c6741d72c4..5d82556ffd 100644
--- a/saleor/graphql/product/tests/test_bulk_delete.py
+++ b/saleor/graphql/product/tests/test_bulk_delete.py
@@ -39,13 +39,13 @@ def category_list():
@pytest.fixture
def product_type_list():
product_type_1 = ProductType.objects.create(
- name="Type 1", slug="type-1", type=ProductTypeKind.NORMAL
+ name="Type 1", slug="type-1", kind=ProductTypeKind.NORMAL
)
product_type_2 = ProductType.objects.create(
- name="Type 2", slug="type-2", type=ProductTypeKind.NORMAL
+ name="Type 2", slug="type-2", kind=ProductTypeKind.NORMAL
)
product_type_3 = ProductType.objects.create(
- name="Type 3", slug="type-3", type=ProductTypeKind.NORMAL
+ name="Type 3", slug="type-3", kind=ProductTypeKind.NORMAL
)
return product_type_1, product_type_2, product_type_3
diff --git a/saleor/graphql/product/tests/test_product.py b/saleor/graphql/product/tests/test_product.py
index 4b5ec5283b..64982b08b9 100644
--- a/saleor/graphql/product/tests/test_product.py
+++ b/saleor/graphql/product/tests/test_product.py
@@ -1775,7 +1775,7 @@ def test_products_query_with_filter_attributes(
slug="custom-type",
has_variants=True,
is_shipping_required=True,
- type=ProductTypeKind.NORMAL,
+ kind=ProductTypeKind.NORMAL,
)
attribute = Attribute.objects.create(slug="new_attr", name="Attr")
attribute.product_types.add(product_type)
@@ -1838,7 +1838,7 @@ def test_products_query_with_filter_numeric_attributes(
product_type = ProductType.objects.create(
name="Custom Type",
slug="custom-type",
- type=ProductTypeKind.NORMAL,
+ kind=ProductTypeKind.NORMAL,
has_variants=True,
is_shipping_required=True,
)
@@ -1916,7 +1916,7 @@ def test_products_query_with_filter_boolean_attributes(
product_type = ProductType.objects.create(
name="Custom Type",
slug="custom-type",
- type=ProductTypeKind.NORMAL,
+ kind=ProductTypeKind.NORMAL,
has_variants=True,
is_shipping_required=True,
)
@@ -1976,7 +1976,7 @@ def test_products_query_with_filter_by_attributes_values_and_range(
product_type = ProductType.objects.create(
name="Custom Type",
slug="custom-type",
- type=ProductTypeKind.NORMAL,
+ kind=ProductTypeKind.NORMAL,
has_variants=True,
is_shipping_required=True,
)
@@ -7193,7 +7193,7 @@ PRODUCT_TYPE_CREATE_MUTATION = """
mutation createProductType(
$name: String,
$slug: String,
- $type: ProductTypeKindEnum,
+ $kind: ProductTypeKindEnum,
$taxCode: String,
$hasVariants: Boolean,
$isShippingRequired: Boolean,
@@ -7204,7 +7204,7 @@ PRODUCT_TYPE_CREATE_MUTATION = """
input: {
name: $name,
slug: $slug,
- type: $type,
+ kind: $kind,
taxCode: $taxCode,
hasVariants: $hasVariants,
isShippingRequired: $isShippingRequired,
@@ -7214,7 +7214,7 @@ PRODUCT_TYPE_CREATE_MUTATION = """
productType {
name
slug
- type
+ kind
isShippingRequired
hasVariants
variantAttributes {
@@ -7267,7 +7267,7 @@ def test_product_type_create_mutation(
query = PRODUCT_TYPE_CREATE_MUTATION
product_type_name = "test type"
slug = "test-type"
- type = ProductTypeKindEnum.NORMAL.name
+ kind = ProductTypeKindEnum.NORMAL.name
has_variants = True
require_shipping = True
product_attributes = product_type.product_attributes.all()
@@ -7282,7 +7282,7 @@ def test_product_type_create_mutation(
variables = {
"name": product_type_name,
"slug": slug,
- "type": type,
+ "kind": kind,
"hasVariants": has_variants,
"taxCode": "wine",
"isShippingRequired": require_shipping,
@@ -7298,7 +7298,7 @@ def test_product_type_create_mutation(
data = content["data"]["productTypeCreate"]["productType"]
assert data["name"] == product_type_name
assert data["slug"] == slug
- assert data["type"] == type
+ assert data["kind"] == kind
assert data["hasVariants"] == has_variants
assert data["isShippingRequired"] == require_shipping
@@ -7333,7 +7333,7 @@ def test_create_gift_card_product_type(
query = PRODUCT_TYPE_CREATE_MUTATION
product_type_name = "test type"
slug = "test-type"
- type = ProductTypeKindEnum.GIFT_CARD.name
+ kind = ProductTypeKindEnum.GIFT_CARD.name
has_variants = True
require_shipping = True
product_attributes = product_type.product_attributes.all()
@@ -7348,7 +7348,7 @@ def test_create_gift_card_product_type(
variables = {
"name": product_type_name,
"slug": slug,
- "type": type,
+ "kind": kind,
"hasVariants": has_variants,
"taxCode": "wine",
"isShippingRequired": require_shipping,
@@ -7364,7 +7364,7 @@ def test_create_gift_card_product_type(
data = content["data"]["productTypeCreate"]["productType"]
assert data["name"] == product_type_name
assert data["slug"] == slug
- assert data["type"] == type
+ assert data["kind"] == kind
assert data["hasVariants"] == has_variants
assert data["isShippingRequired"] == require_shipping
@@ -7406,7 +7406,7 @@ def test_create_product_type_with_rich_text_attribute(
variables = {
"name": product_type_name,
"slug": slug,
- "type": ProductTypeKindEnum.NORMAL.name,
+ "kind": ProductTypeKindEnum.NORMAL.name,
"productAttributes": product_attributes_ids,
}
@@ -7465,7 +7465,7 @@ def test_create_product_type_with_date_attribute(
query = PRODUCT_TYPE_CREATE_MUTATION
product_type_name = "test type"
slug = "test-type"
- type = ProductTypeKindEnum.NORMAL.name
+ kind = ProductTypeKindEnum.NORMAL.name
product_type.product_attributes.add(date_attribute)
product_type.product_attributes.add(date_time_attribute)
@@ -7478,7 +7478,7 @@ def test_create_product_type_with_date_attribute(
variables = {
"name": product_type_name,
"slug": slug,
- "type": type,
+ "kind": kind,
"productAttributes": product_attributes_ids,
}
@@ -7496,7 +7496,7 @@ def test_create_product_type_with_date_attribute(
assert not errors
assert data["name"] == product_type_name
assert data["slug"] == slug
- assert data["type"] == type
+ assert data["kind"] == kind
for attribute in expected_attribute:
assert attribute in data["productAttributes"]
@@ -7511,7 +7511,7 @@ def test_create_product_type_with_boolean_attribute(
query = PRODUCT_TYPE_CREATE_MUTATION
product_type_name = "test type"
slug = "test-type"
- type = ProductTypeKindEnum.NORMAL.name
+ kind = ProductTypeKindEnum.NORMAL.name
product_type.product_attributes.add(boolean_attribute)
product_attributes_ids = [
@@ -7522,7 +7522,7 @@ def test_create_product_type_with_boolean_attribute(
variables = {
"name": product_type_name,
"slug": slug,
- "type": type,
+ "kind": kind,
"productAttributes": product_attributes_ids,
}
@@ -7536,7 +7536,7 @@ def test_create_product_type_with_boolean_attribute(
assert not errors
assert data["name"] == product_type_name
assert data["slug"] == slug
- assert data["type"] == type
+ assert data["kind"] == kind
assert {"choices": {"edges": []}, "name": "Boolean"} in data["productAttributes"]
@@ -7560,7 +7560,7 @@ def test_create_product_type_with_given_slug(
variables = {
"name": name,
"slug": input_slug,
- "type": ProductTypeKindEnum.NORMAL.name,
+ "kind": ProductTypeKindEnum.NORMAL.name,
}
response = staff_api_client.post_graphql(
query, variables, permissions=[permission_manage_product_types_and_attributes]
@@ -7576,10 +7576,10 @@ def test_create_product_type_with_unicode_in_name(
):
query = PRODUCT_TYPE_CREATE_MUTATION
name = "わたし わ にっぽん です"
- type = ProductTypeKindEnum.NORMAL.name
+ kind = ProductTypeKindEnum.NORMAL.name
variables = {
"name": name,
- "type": type,
+ "kind": kind,
}
response = staff_api_client.post_graphql(
query, variables, permissions=[permission_manage_product_types_and_attributes]
@@ -7589,7 +7589,7 @@ def test_create_product_type_with_unicode_in_name(
assert not data["errors"]
assert data["productType"]["name"] == name
assert data["productType"]["slug"] == "わたし-わ-にっぽん-です"
- assert data["productType"]["type"] == type
+ assert data["productType"]["kind"] == kind
def test_create_product_type_create_with_negative_weight(
@@ -7646,7 +7646,7 @@ def test_product_type_create_mutation_not_valid_attributes(
variables = {
"name": product_type_name,
"slug": slug,
- "type": ProductTypeKindEnum.NORMAL.name,
+ "kind": ProductTypeKindEnum.NORMAL.name,
"hasVariants": has_variants,
"taxCode": "wine",
"isShippingRequired": require_shipping,
@@ -8010,16 +8010,16 @@ def test_update_product_type_type(
permission_manage_product_types_and_attributes,
):
query = """
- mutation($id: ID!, $type: ProductTypeKindEnum) {
+ mutation($id: ID!, $kind: ProductTypeKindEnum) {
productTypeUpdate(
id: $id
input: {
- type: $type
+ kind: $kind
}
) {
productType{
name
- type
+ kind
}
errors {
field
@@ -8029,11 +8029,11 @@ def test_update_product_type_type(
}
}
"""
- type = ProductTypeKindEnum.GIFT_CARD.name
- assert product_type.type != type
+ kind = ProductTypeKindEnum.GIFT_CARD.name
+ assert product_type.kind != kind
node_id = graphene.Node.to_global_id("ProductType", product_type.id)
- variables = {"type": type, "id": node_id}
+ variables = {"kind": kind, "id": node_id}
response = staff_api_client.post_graphql(
query, variables, permissions=[permission_manage_product_types_and_attributes]
@@ -8042,7 +8042,7 @@ def test_update_product_type_type(
data = content["data"]["productTypeUpdate"]
errors = data["errors"]
assert not errors
- assert data["productType"]["type"] == type
+ assert data["productType"]["kind"] == kind
PRODUCT_TYPE_DELETE_MUTATION = """
@@ -9962,7 +9962,7 @@ def test_product_type_filter_unassigned_attributes(
expected_attribute = product_type_attribute_list[0]
query = QUERY_AVAILABLE_ATTRIBUTES
product_type = ProductType.objects.create(
- name="Empty Type", type=ProductTypeKind.NORMAL
+ name="Empty Type", kind=ProductTypeKind.NORMAL
)
product_type_id = graphene.Node.to_global_id("ProductType", product_type.pk)
filters = {"search": expected_attribute.name}
diff --git a/saleor/graphql/product/tests/test_product_filtering_and_sorting_with_channels.py b/saleor/graphql/product/tests/test_product_filtering_and_sorting_with_channels.py
index ecb600ae88..e3b9fa71b7 100644
--- a/saleor/graphql/product/tests/test_product_filtering_and_sorting_with_channels.py
+++ b/saleor/graphql/product/tests/test_product_filtering_and_sorting_with_channels.py
@@ -18,7 +18,7 @@ from ...tests.utils import assert_graphql_error_with_message, get_graphql_conten
@pytest.fixture
def products_for_sorting_with_channels(category, channel_USD, channel_PLN):
- product_type = ProductType.objects.create(name="Apple", type=ProductTypeKind.NORMAL)
+ product_type = ProductType.objects.create(name="Apple", kind=ProductTypeKind.NORMAL)
products = Product.objects.bulk_create(
[
Product(
diff --git a/saleor/graphql/product/tests/test_product_pagination.py b/saleor/graphql/product/tests/test_product_pagination.py
index 24ab7b9a09..3d669f5590 100644
--- a/saleor/graphql/product/tests/test_product_pagination.py
+++ b/saleor/graphql/product/tests/test_product_pagination.py
@@ -307,7 +307,7 @@ def products_for_pagination(
product_type, color_attribute, category, warehouse, channel_USD
):
product_type2 = ProductType.objects.create(
- name="Apple", type=ProductTypeKind.NORMAL
+ name="Apple", kind=ProductTypeKind.NORMAL
)
products = Product.objects.bulk_create(
[
diff --git a/saleor/graphql/product/tests/test_product_sorting_attributes.py b/saleor/graphql/product/tests/test_product_sorting_attributes.py
index 91a4ffa1bf..f9bdf9ce8d 100644
--- a/saleor/graphql/product/tests/test_product_sorting_attributes.py
+++ b/saleor/graphql/product/tests/test_product_sorting_attributes.py
@@ -561,7 +561,7 @@ def test_sort_product_not_having_attribute_data(api_client, category, count_quer
name="Apples", slug="apples"
)
other_product_type = product_models.ProductType.objects.create(
- name="Chocolates", slug="chocolates", type=ProductTypeKind.NORMAL
+ name="Chocolates", slug="chocolates", kind=ProductTypeKind.NORMAL
)
# Assign an attribute to the product type
diff --git a/saleor/graphql/product/types/products.py b/saleor/graphql/product/types/products.py
index f4d97f5e95..de7c925c45 100644
--- a/saleor/graphql/product/types/products.py
+++ b/saleor/graphql/product/types/products.py
@@ -93,7 +93,7 @@ from ..dataloaders import (
VariantChannelListingByVariantIdLoader,
VariantsChannelListingByProductIdAndChannelSlugLoader,
)
-from ..enums import VariantAttributeScope
+from ..enums import ProductTypeKindEnum, VariantAttributeScope
from ..filters import ProductFilterInput
from ..sorters import ProductOrder
from .channels import (
@@ -927,6 +927,7 @@ class Product(ChannelContextTypeWithMetadata, CountableDjangoObjectType):
@key(fields="id")
class ProductType(CountableDjangoObjectType):
+ kind = ProductTypeKindEnum(description="The product type kind.")
products = ChannelContextFilterConnectionField(
Product,
channel=graphene.String(
@@ -970,7 +971,6 @@ class ProductType(CountableDjangoObjectType):
"is_shipping_required",
"name",
"slug",
- "type",
"weight",
"tax_type",
]
diff --git a/saleor/graphql/schema.graphql b/saleor/graphql/schema.graphql
index 4031e15a37..19652f965d 100644
--- a/saleor/graphql/schema.graphql
+++ b/saleor/graphql/schema.graphql
@@ -5376,13 +5376,13 @@ type ProductType implements Node & ObjectWithMetadata {
id: ID!
name: String!
slug: String!
- type: ProductTypeType!
hasVariants: Boolean!
isShippingRequired: Boolean!
isDigital: Boolean!
weight: Weight
privateMetadata: [MetadataItem]!
metadata: [MetadataItem]!
+ kind: ProductTypeKindEnum
products(channel: String, before: String, after: String, first: Int, last: Int): ProductCountableConnection @deprecated(reason: "This field will be removed in Saleor 4.0. Use the top-level `products` query with the `productTypes` filter.")
taxType: TaxType
variantAttributes(variantSelection: VariantAttributeScope): [Attribute]
@@ -5440,7 +5440,7 @@ input ProductTypeFilterInput {
input ProductTypeInput {
name: String
slug: String
- type: ProductTypeKindEnum
+ kind: ProductTypeKindEnum
hasVariants: Boolean
productAttributes: [ID]
variantAttributes: [ID]
@@ -5472,11 +5472,6 @@ input ProductTypeSortingInput {
field: ProductTypeSortField!
}
-enum ProductTypeType {
- NORMAL
- GIFT_CARD
-}
-
type ProductTypeUpdate {
productErrors: [ProductError!]! @deprecated(reason: "This field will be removed in Saleor 4.0. Use `errors` field instead.")
errors: [ProductError!]!
diff --git a/saleor/plugins/avatax/tests/test_avatax.py b/saleor/plugins/avatax/tests/test_avatax.py
index de76b5f974..5f10b1b06f 100644
--- a/saleor/plugins/avatax/tests/test_avatax.py
+++ b/saleor/plugins/avatax/tests/test_avatax.py
@@ -949,7 +949,7 @@ def test_get_checkout_line_tax_rate_for_product_type_with_non_taxable_product(
manager = get_plugins_manager()
product_type = ProductType.objects.create(
- name="non-taxable", type=ProductTypeKind.NORMAL
+ name="non-taxable", kind=ProductTypeKind.NORMAL
)
product2 = product_with_two_variants
product2.product_type = product_type
diff --git a/saleor/product/migrations/0148_producttype_type.py b/saleor/product/migrations/0148_producttype_type.py
index bf536734ce..d00e32471e 100644
--- a/saleor/product/migrations/0148_producttype_type.py
+++ b/saleor/product/migrations/0148_producttype_type.py
@@ -12,7 +12,7 @@ class Migration(migrations.Migration):
operations = [
migrations.AddField(
model_name="producttype",
- name="type",
+ name="kind",
field=models.CharField(
choices=[
("normal", "A standard product type."),
diff --git a/saleor/product/models.py b/saleor/product/models.py
index 5f75835838..f913572e74 100644
--- a/saleor/product/models.py
+++ b/saleor/product/models.py
@@ -119,7 +119,7 @@ class CategoryTranslation(SeoModelTranslation):
class ProductType(ModelWithMetadata):
name = models.CharField(max_length=250)
slug = models.SlugField(max_length=255, unique=True, allow_unicode=True)
- type = models.CharField(max_length=32, choices=ProductTypeKind.CHOICES)
+ kind = models.CharField(max_length=32, choices=ProductTypeKind.CHOICES)
has_variants = models.BooleanField(default=True)
is_shipping_required = models.BooleanField(default=True)
is_digital = models.BooleanField(default=False)
diff --git a/saleor/product/tests/test_generate_and_set_variant_name.py b/saleor/product/tests/test_generate_and_set_variant_name.py
index 065fe4339b..7cea2cba72 100644
--- a/saleor/product/tests/test_generate_and_set_variant_name.py
+++ b/saleor/product/tests/test_generate_and_set_variant_name.py
@@ -20,7 +20,7 @@ def variant_with_no_attributes(category, channel_USD):
name="Test product type",
has_variants=True,
is_shipping_required=True,
- type=ProductTypeKind.NORMAL,
+ kind=ProductTypeKind.NORMAL,
)
product = Product.objects.create(
name="Test product",
diff --git a/saleor/product/tests/test_product.py b/saleor/product/tests/test_product.py
index 1de59b2ad2..b090e2a71c 100644
--- a/saleor/product/tests/test_product.py
+++ b/saleor/product/tests/test_product.py
@@ -37,14 +37,14 @@ def test_filtering_by_attribute(
name="New class",
slug="new-class1",
has_variants=True,
- type=ProductTypeKind.NORMAL,
+ kind=ProductTypeKind.NORMAL,
)
product_type_a.product_attributes.add(color_attribute)
product_type_b = models.ProductType.objects.create(
name="New class",
slug="new-class2",
has_variants=True,
- type=ProductTypeKind.NORMAL,
+ kind=ProductTypeKind.NORMAL,
)
product_type_b.variant_attributes.add(color_attribute)
product_a = models.Product.objects.create(
diff --git a/saleor/tests/fixtures.py b/saleor/tests/fixtures.py
index dfdb14db72..7c526de1de 100644
--- a/saleor/tests/fixtures.py
+++ b/saleor/tests/fixtures.py
@@ -1443,7 +1443,7 @@ def product_type(color_attribute, size_attribute):
product_type = ProductType.objects.create(
name="Default Type",
slug="default-type",
- type=ProductTypeKind.NORMAL,
+ kind=ProductTypeKind.NORMAL,
has_variants=True,
is_shipping_required=True,
)
@@ -1459,7 +1459,7 @@ def product_type_with_rich_text_attribute(
product_type = ProductType.objects.create(
name="Default Type",
slug="default-type",
- type=ProductTypeKind.NORMAL,
+ kind=ProductTypeKind.NORMAL,
has_variants=True,
is_shipping_required=True,
)
@@ -1475,7 +1475,7 @@ def product_type_without_variant():
slug="type",
has_variants=False,
is_shipping_required=True,
- type=ProductTypeKind.NORMAL,
+ kind=ProductTypeKind.NORMAL,
)
return product_type
@@ -1672,7 +1672,7 @@ def product_with_variant_with_two_attributes(
product_type = ProductType.objects.create(
name="Type with two variants",
slug="two-variants",
- type=ProductTypeKind.NORMAL,
+ kind=ProductTypeKind.NORMAL,
has_variants=True,
is_shipping_required=True,
)
@@ -1724,7 +1724,7 @@ def product_with_variant_with_external_media(
product_type = ProductType.objects.create(
name="Type with two variants",
slug="two-variants",
- type=ProductTypeKind.NORMAL,
+ kind=ProductTypeKind.NORMAL,
has_variants=True,
is_shipping_required=True,
)
@@ -1782,7 +1782,7 @@ def product_with_variant_with_file_attribute(
product_type = ProductType.objects.create(
name="Type with variant and file attribute",
slug="type-with-file-attribute",
- type=ProductTypeKind.NORMAL,
+ kind=ProductTypeKind.NORMAL,
has_variants=True,
is_shipping_required=True,
)
@@ -2008,7 +2008,7 @@ def product_without_shipping(category, warehouse, channel_USD):
product_type = ProductType.objects.create(
name="Type with no shipping",
slug="no-shipping",
- type=ProductTypeKind.NORMAL,
+ kind=ProductTypeKind.NORMAL,
has_variants=False,
is_shipping_required=False,
)
@@ -3969,7 +3969,7 @@ def digital_content(category, media_root, warehouse, channel_USD) -> DigitalCont
product_type = ProductType.objects.create(
name="Digital Type",
slug="digital-type",
- type=ProductTypeKind.NORMAL,
+ kind=ProductTypeKind.NORMAL,
has_variants=True,
is_shipping_required=False,
is_digital=True,