Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Metadata added to checkout and order lines (#10040)
SzymJa68553e1a55e
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex c3e0d2cda5..a5e47583f4 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -10,6 +10,7 @@ All notable, unreleased changes to this project will be documented in this file.- Introduce plain text attribute - #9907 by @IKarbowiak- Stop auto-assigning default addresses to checkout - #9933 by @SzymJ- Added `OrderFilter.numbers` filter - #9967 by @SzymJ+- Added `metadata` fields to `OrderLine` and `CheckoutLine` models - #10040 by @SzymJ#### Saleor Apps- Add webhooks `PAGE_TYPE_CREATED`, `PAGE_TYPE_UPDATED` and `PAGE_TYPE_DELETED` - #9859 by @SzymJdiff --git a/saleor/checkout/complete_checkout.py b/saleor/checkout/complete_checkout.pyindex a5d424dd74..1ce09ce589 100644--- a/saleor/checkout/complete_checkout.py+++ b/saleor/checkout/complete_checkout.py@@ -268,6 +268,8 @@ def _create_line_for_order(unit_discount_value=discount_amount.amount, # we store value as fixed discountbase_unit_price=base_prices_data.price_with_discounts,undiscounted_base_unit_price=base_prices_data.undiscounted_price,+ metadata=checkout_line.metadata,+ private_metadata=checkout_line.private_metadata,)is_digital = line.is_digitalline_info = OrderLineInfo(diff --git a/saleor/checkout/migrations/0049_auto_20220621_0850.py b/saleor/checkout/migrations/0049_auto_20220621_0850.pynew file mode 100644index 0000000000..26fa9a99c8--- /dev/null+++ b/saleor/checkout/migrations/0049_auto_20220621_0850.py@@ -0,0 +1,47 @@+# Generated by Django 3.2.13 on 2022-06-21 08:50++import django.contrib.postgres.indexes+from django.db import migrations, models+import saleor.core.utils.json_serializer+++class Migration(migrations.Migration):++ dependencies = [+ ("checkout", "0048_alter_checkoutline_options"),+ ]++ operations = [+ migrations.AddField(+ model_name="checkoutline",+ name="metadata",+ field=models.JSONField(+ blank=True,+ default=dict,+ encoder=saleor.core.utils.json_serializer.CustomJsonEncoder,+ null=True,+ ),+ ),+ migrations.AddField(+ model_name="checkoutline",+ name="private_metadata",+ field=models.JSONField(+ blank=True,+ default=dict,+ encoder=saleor.core.utils.json_serializer.CustomJsonEncoder,+ null=True,+ ),+ ),+ migrations.AddIndex(+ model_name="checkoutline",+ index=django.contrib.postgres.indexes.GinIndex(+ fields=["private_metadata"], name="checkoutline_p_meta_idx"+ ),+ ),+ migrations.AddIndex(+ model_name="checkoutline",+ index=django.contrib.postgres.indexes.GinIndex(+ fields=["metadata"], name="checkoutline_meta_idx"+ ),+ ),+ ]diff --git a/saleor/checkout/models.py b/saleor/checkout/models.pyindex deca353f25..0d2526a8f5 100644--- a/saleor/checkout/models.py+++ b/saleor/checkout/models.py@@ -171,7 +171,7 @@ class Checkout(ModelWithMetadata):return country_code-class CheckoutLine(models.Model):+class CheckoutLine(ModelWithMetadata):"""A single checkout line.Multiple lines in the same checkout can refer to the same product variant if@@ -195,7 +195,7 @@ class CheckoutLine(models.Model):null=True,)- class Meta:+ class Meta(ModelWithMetadata.Meta):ordering = ("created_at", "id")def __str__(self):diff --git a/saleor/graphql/checkout/tests/test_checkout.py b/saleor/graphql/checkout/tests/test_checkout.pyindex e600862fa4..fd404e6ee0 100644--- a/saleor/graphql/checkout/tests/test_checkout.py+++ b/saleor/graphql/checkout/tests/test_checkout.py@@ -4818,6 +4818,57 @@ def test_query_checkout_lines(assert expected_lines_ids == checkout_lines_ids+def test_query_checkout_lines_with_meta(+ checkout_with_item, staff_api_client, permission_manage_checkouts+):+ query = """+ {+ checkoutLines(first: 20) {+ edges {+ node {+ id+ metadata {+ key+ value+ }+ privateMetadata {+ key+ value+ }+ }+ }+ }+ }+ """+ checkout = checkout_with_item+ items = [item for item in checkout]++ metadata_key = "md key"+ metadata_value = "md value"++ for item in items:+ item.store_value_in_private_metadata({metadata_key: metadata_value})+ item.store_value_in_metadata({metadata_key: metadata_value})+ item.save()++ response = staff_api_client.post_graphql(+ query, permissions=[permission_manage_checkouts]+ )+ content = get_graphql_content(response)+ lines = content["data"]["checkoutLines"]["edges"]+ expected_lines = [+ {+ "node": {+ "id": graphene.Node.to_global_id("CheckoutLine", item.pk),+ "metadata": [{"key": metadata_key, "value": metadata_value}],+ "privateMetadata": [{"key": metadata_key, "value": metadata_value}],+ }+ }+ for item in items+ ]+ assert lines == expected_lines++def test_clean_checkout(checkout_with_item, payment_dummy, address, shipping_method):checkout = checkout_with_itemcheckout.shipping_address = addressdiff --git a/saleor/graphql/checkout/tests/test_order_create_from_checkout.py b/saleor/graphql/checkout/tests/test_order_create_from_checkout.pyindex d5f91647a8..7473321658 100644--- a/saleor/graphql/checkout/tests/test_order_create_from_checkout.py+++ b/saleor/graphql/checkout/tests/test_order_create_from_checkout.py@@ -105,8 +105,18 @@ def test_order_from_checkout(checkout.save()checkout_line = checkout.lines.first()++ metadata_key = "md key"+ metadata_value = "md value"++ checkout_line.store_value_in_private_metadata({metadata_key: metadata_value})+ checkout_line.store_value_in_metadata({metadata_key: metadata_value})+ checkout_line.save()+checkout_line_quantity = checkout_line.quantitycheckout_line_variant = checkout_line.variant+ checkout_line_metadata = checkout_line.metadata+ checkout_line_private_metadata = checkout_line.private_metadatamanager = get_plugins_manager()lines, _ = fetch_checkout_lines(checkout)@@ -143,6 +153,8 @@ def test_order_from_checkout(order_line = order.lines.first()assert checkout_line_quantity == order_line.quantityassert checkout_line_variant == order_line.variant+ assert checkout_line_metadata == order_line.metadata+ assert checkout_line_private_metadata == order_line.private_metadataassert order.shipping_address == addressassert order.shipping_method == checkout.shipping_methodassert order.search_vectordiff --git a/saleor/graphql/checkout/types.py b/saleor/graphql/checkout/types.pyindex 3e185a404a..79a40e52a4 100644--- a/saleor/graphql/checkout/types.py+++ b/saleor/graphql/checkout/types.py@@ -114,7 +114,7 @@ class CheckoutLine(ModelObjectType):class Meta:description = "Represents an item in the checkout."- interfaces = [graphene.relay.Node]+ interfaces = [graphene.relay.Node, ObjectWithMetadata]model = models.CheckoutLine@staticmethoddiff --git a/saleor/graphql/meta/permissions.py b/saleor/graphql/meta/permissions.pyindex 2211e38e7c..04a8619fd7 100644--- a/saleor/graphql/meta/permissions.py+++ b/saleor/graphql/meta/permissions.py@@ -154,6 +154,7 @@ PUBLIC_META_PERMISSION_MAP = {"Attribute": attribute_permissions,"Category": product_permissions,"Checkout": no_permissions,+ "CheckoutLine": no_permissions,"Collection": product_permissions,"DigitalContent": product_permissions,"Fulfillment": order_permissions,@@ -162,6 +163,7 @@ PUBLIC_META_PERMISSION_MAP = {"Menu": menu_permissions,"MenuItem": menu_permissions,"Order": no_permissions,+ "OrderLine": no_permissions,"Page": page_permissions,"PageType": page_type_permissions,"Payment": public_payment_permissions,@@ -183,6 +185,7 @@ PRIVATE_META_PERMISSION_MAP = {"Attribute": attribute_permissions,"Category": product_permissions,"Checkout": checkout_permissions,+ "CheckoutLine": checkout_permissions,"Collection": product_permissions,"DigitalContent": product_permissions,"Fulfillment": order_permissions,@@ -191,6 +194,7 @@ PRIVATE_META_PERMISSION_MAP = {"Menu": menu_permissions,"MenuItem": menu_permissions,"Order": order_permissions,+ "OrderLine": order_permissions,"Page": page_permissions,"PageType": page_type_permissions,"Payment": private_payment_permissions,diff --git a/saleor/graphql/meta/resolvers.py b/saleor/graphql/meta/resolvers.pyindex 49edfd60b6..b995e29331 100644--- a/saleor/graphql/meta/resolvers.py+++ b/saleor/graphql/meta/resolvers.py@@ -45,11 +45,13 @@ def resolve_object_with_metadata_type(instance):attribute_models.Attribute: attribute_types.Attribute,product_models.Category: product_types.Category,checkout_models.Checkout: checkout_types.Checkout,+ checkout_models.CheckoutLine: checkout_types.CheckoutLine,product_models.Collection: product_types.Collection,product_models.DigitalContent: product_types.DigitalContent,order_models.Fulfillment: order_types.Fulfillment,giftcard_models.GiftCard: giftcard_types.GiftCard,order_models.Order: order_types.Order,+ order_models.OrderLine: order_types.OrderLine,invoice_models.Invoice: invoice_types.Invoice,page_models.Page: page_types.Page,page_models.PageType: page_types.PageType,diff --git a/saleor/graphql/meta/tests/test_meta_mutations.py b/saleor/graphql/meta/tests/test_meta_mutations.pyindex bbced425b9..28d39db3ce 100644--- a/saleor/graphql/meta/tests/test_meta_mutations.py+++ b/saleor/graphql/meta/tests/test_meta_mutations.py@@ -387,6 +387,21 @@ def test_add_public_metadata_for_checkout(api_client, checkout):)+def test_add_public_metadata_for_checkout_line(api_client, checkout_line):+ # given+ checkout_line_id = graphene.Node.to_global_id("CheckoutLine", checkout_line.pk)++ # when+ response = execute_update_public_metadata_for_item(+ api_client, None, checkout_line_id, "CheckoutLine"+ )++ # then+ assert item_contains_proper_public_metadata(+ response["data"]["updateMetadata"]["item"], checkout_line, checkout_line_id+ )++def test_add_public_metadata_for_checkout_by_token(api_client, checkout):# givencheckout_id = graphene.Node.to_global_id("Checkout", checkout.pk)@@ -479,6 +494,21 @@ def test_add_public_metadata_for_draft_order_by_token(api_client, draft_order):)+def test_add_public_metadata_for_order_line(api_client, order_line):+ # given+ order_line_id = graphene.Node.to_global_id("OrderLine", order_line.pk)++ # when+ response = execute_update_public_metadata_for_item(+ api_client, None, order_line_id, "OrderLine"+ )++ # then+ assert item_contains_proper_public_metadata(+ response["data"]["updateMetadata"]["item"], order_line, order_line_id+ )++def test_add_public_metadata_for_product_attribute(staff_api_client, permission_manage_product_types_and_attributes, color_attribute):@@ -899,6 +929,46 @@ def test_update_public_metadata_for_item(api_client, checkout):)+def test_update_public_metadata_for_checkout_line(api_client, checkout_line):+ # given+ checkout_line.store_value_in_metadata({PUBLIC_KEY: PUBLIC_VALUE})+ checkout_line.save(update_fields=["metadata"])+ checkout_line_id = graphene.Node.to_global_id("CheckoutLine", checkout_line.pk)++ # when+ response = execute_update_public_metadata_for_item(+ api_client, None, checkout_line_id, "CheckoutLine", value="NewMetaValue"+ )++ # then+ assert item_contains_proper_public_metadata(+ response["data"]["updateMetadata"]["item"],+ checkout_line,+ checkout_line_id,+ value="NewMetaValue",+ )+++def test_update_public_metadata_for_order_line(api_client, order_line):+ # given+ order_line.store_value_in_metadata({PUBLIC_KEY: PUBLIC_VALUE})+ order_line.save(update_fields=["metadata"])+ order_line_id = graphene.Node.to_global_id("OrderLine", order_line.pk)++ # when+ response = execute_update_public_metadata_for_item(+ api_client, None, order_line_id, "OrderLine", value="NewMetaValue"+ )++ # then+ assert item_contains_proper_public_metadata(+ response["data"]["updateMetadata"]["item"],+ order_line,+ order_line_id,+ value="NewMetaValue",+ )++@pytest.mark.django_db(transaction=True)def test_update_public_metadata_for_item_on_deleted_instance(api_client, checkout):checkout.store_value_in_metadata({PUBLIC_KEY: PUBLIC_VALUE})@@ -1327,6 +1397,23 @@ def test_delete_public_metadata_for_checkout_by_token(api_client, checkout):)+def test_delete_public_metadata_for_checkout_line(api_client, checkout_line):+ # given+ checkout_line.store_value_in_metadata({PUBLIC_KEY: PUBLIC_VALUE})+ checkout_line.save(update_fields=["metadata"])+ checkout_line_id = graphene.Node.to_global_id("CheckoutLine", checkout_line.pk)++ # when+ response = execute_clear_public_metadata_for_item(+ api_client, None, checkout_line_id, "CheckoutLine"+ )++ # then+ assert item_without_public_metadata(+ response["data"]["deleteMetadata"]["item"], checkout_line, checkout_line_id+ )++def test_delete_public_metadata_for_order_by_id(api_client, order):# givenorder.store_value_in_metadata({PUBLIC_KEY: PUBLIC_VALUE})@@ -1395,6 +1482,23 @@ def test_delete_public_metadata_for_draft_order_by_token(api_client, draft_order)+def test_delete_public_metadata_for_order_line(api_client, order_line):+ # given+ order_line.store_value_in_metadata({PUBLIC_KEY: PUBLIC_VALUE})+ order_line.save(update_fields=["metadata"])+ order_line_id = graphene.Node.to_global_id("OrderLine", order_line.pk)++ # when+ response = execute_clear_public_metadata_for_item(+ api_client, None, order_line_id, "OrderLine"+ )++ # then+ assert item_without_public_metadata(+ response["data"]["deleteMetadata"]["item"], order_line, order_line_id+ )++def test_delete_public_metadata_for_product_attribute(staff_api_client, permission_manage_product_types_and_attributes, color_attribute):@@ -2117,6 +2221,25 @@ def test_add_private_metadata_for_checkout()+def test_add_private_metadata_for_checkout_line(+ staff_api_client, checkout_line, permission_manage_checkouts+):+ # given+ checkout_line_id = graphene.Node.to_global_id("CheckoutLine", checkout_line.pk)++ # when+ response = execute_update_private_metadata_for_item(+ staff_api_client, permission_manage_checkouts, checkout_line_id, "CheckoutLine"+ )++ # then+ assert item_contains_proper_private_metadata(+ response["data"]["updatePrivateMetadata"]["item"],+ checkout_line,+ checkout_line_id,+ )++def test_add_private_metadata_for_checkout_by_token(staff_api_client, checkout, permission_manage_checkouts):@@ -2202,6 +2325,23 @@ def test_add_private_metadata_for_draft_order_by_token()+def test_add_private_metadata_for_order_line(+ staff_api_client, order_line, permission_manage_orders+):+ # given+ order_line_id = graphene.Node.to_global_id("OrderLine", order_line.pk)++ # when+ response = execute_update_private_metadata_for_item(+ staff_api_client, permission_manage_orders, order_line_id, "OrderLine"+ )++ # then+ assert item_contains_proper_private_metadata(+ response["data"]["updatePrivateMetadata"]["item"], order_line, order_line_id+ )++def test_add_private_metadata_for_product_attribute(staff_api_client, permission_manage_product_types_and_attributes, color_attribute):@@ -2741,6 +2881,58 @@ def test_update_private_metadata_by_customer(user_api_client, payment):assert_no_permission(response)+def test_update_private_metadata_for_checkout_line(+ staff_api_client, checkout_line, permission_manage_checkouts+):+ # given+ checkout_line.store_value_in_metadata({PUBLIC_KEY: PUBLIC_VALUE})+ checkout_line.save(update_fields=["private_metadata"])+ checkout_line_id = graphene.Node.to_global_id("CheckoutLine", checkout_line.pk)++ # when+ response = execute_update_private_metadata_for_item(+ staff_api_client,+ permission_manage_checkouts,+ checkout_line_id,+ "CheckoutLine",+ value="NewMetaValue",+ )++ # then+ assert item_contains_proper_private_metadata(+ response["data"]["updatePrivateMetadata"]["item"],+ checkout_line,+ checkout_line_id,+ value="NewMetaValue",+ )+++def test_update_private_metadata_for_order_line(+ staff_api_client, order_line, permission_manage_orders+):+ # given+ order_line.store_value_in_metadata({PUBLIC_KEY: PUBLIC_VALUE})+ order_line.save(update_fields=["private_metadata"])+ order_line_id = graphene.Node.to_global_id("OrderLine", order_line.pk)++ # when+ response = execute_update_private_metadata_for_item(+ staff_api_client,+ permission_manage_orders,+ order_line_id,+ "OrderLine",+ value="NewMetaValue",+ )++ # then+ assert item_contains_proper_private_metadata(+ response["data"]["updatePrivateMetadata"]["item"],+ order_line,+ order_line_id,+ value="NewMetaValue",+ )++def test_add_private_metadata_for_warehouse(staff_api_client, permission_manage_products, warehouse):@@ -3052,6 +3244,27 @@ def test_delete_private_metadata_for_checkout_by_token()+def test_delete_private_metadata_for_checkout_line(+ staff_api_client, checkout_line, permission_manage_checkouts+):+ # given+ checkout_line.store_value_in_private_metadata({PRIVATE_KEY: PRIVATE_VALUE})+ checkout_line.save(update_fields=["private_metadata"])+ checkout_line_id = graphene.Node.to_global_id("CheckoutLine", checkout_line.pk)++ # when+ response = execute_clear_private_metadata_for_item(+ staff_api_client, permission_manage_checkouts, checkout_line_id, "CheckoutLine"+ )++ # then+ assert item_without_private_metadata(+ response["data"]["deletePrivateMetadata"]["item"],+ checkout_line,+ checkout_line_id,+ )++def test_delete_private_metadata_for_order_by_id(staff_api_client, order, permission_manage_orders):@@ -3128,6 +3341,25 @@ def test_delete_private_metadata_for_draft_order_by_token()+def test_delete_private_metadata_for_order_line(+ staff_api_client, order_line, permission_manage_orders+):+ # given+ order_line.store_value_in_private_metadata({PRIVATE_KEY: PRIVATE_VALUE})+ order_line.save(update_fields=["private_metadata"])+ order_line_id = graphene.Node.to_global_id("OrderLine", order_line.pk)++ # when+ response = execute_clear_private_metadata_for_item(+ staff_api_client, permission_manage_orders, order_line_id, "OrderLine"+ )++ # then+ assert item_without_private_metadata(+ response["data"]["deletePrivateMetadata"]["item"], order_line, order_line_id+ )++def test_delete_private_metadata_for_product_attribute(staff_api_client, permission_manage_product_types_and_attributes, color_attribute):diff --git a/saleor/graphql/order/tests/test_order.py b/saleor/graphql/order/tests/test_order.pyindex c4370f7887..35a82b5a04 100644--- a/saleor/graphql/order/tests/test_order.py+++ b/saleor/graphql/order/tests/test_order.py@@ -177,6 +177,14 @@ def test_orderline_query(staff_api_client, permission_manage_orders, fulfilled_oamount}}+ metadata {+ key+ value+ }+ privateMetadata {+ key+ value+ }}}}@@ -184,6 +192,12 @@ def test_orderline_query(staff_api_client, permission_manage_orders, fulfilled_o}"""line = order.lines.first()++ metadata_key = "md key"+ metadata_value = "md value"++ line.store_value_in_private_metadata({metadata_key: metadata_value})+ line.store_value_in_metadata({metadata_key: metadata_value})line.save()staff_api_client.user.user_permissions.add(permission_manage_orders)@@ -197,7 +211,12 @@ def test_orderline_query(staff_api_client, permission_manage_orders, fulfilled_oassert first_order_data_line["variant"]["id"] == variant_idassert first_order_data_line["quantity"] == line.quantityassert first_order_data_line["unitPrice"]["currency"] == line.unit_price.currency-+ assert first_order_data_line["metadata"] == [+ {"key": metadata_key, "value": metadata_value}+ ]+ assert first_order_data_line["privateMetadata"] == [+ {"key": metadata_key, "value": metadata_value}+ ]expected_unit_price = Money(amount=str(first_order_data_line["unitPrice"]["gross"]["amount"]),currency="USD",diff --git a/saleor/graphql/order/types.py b/saleor/graphql/order/types.pyindex d40ae1ce53..c21dc85269 100644--- a/saleor/graphql/order/types.py+++ b/saleor/graphql/order/types.py@@ -587,7 +587,7 @@ class OrderLine(ModelObjectType):class Meta:description = "Represents order line of particular order."model = models.OrderLine- interfaces = [relay.Node]+ interfaces = [relay.Node, ObjectWithMetadata]@staticmethod@traced_resolverdiff --git a/saleor/graphql/schema.graphql b/saleor/graphql/schema.graphqlindex 0be5338967..fef393f147 100644--- a/saleor/graphql/schema.graphql+++ b/saleor/graphql/schema.graphql@@ -7795,8 +7795,54 @@ type GiftCardTag implements Node {}"""Represents an item in the checkout."""-type CheckoutLine implements Node {+type CheckoutLine implements Node & ObjectWithMetadata {id: ID!++ """List of private metadata items. Requires staff permissions to access."""+ privateMetadata: [MetadataItem!]!++ """+ A single key from private metadata. Requires staff permissions to access.++ Tip: Use GraphQL aliases to fetch multiple keys.++ Added in Saleor 3.3.++ Note: this API is currently in Feature Preview and can be subject to changes at later point.+ """+ privateMetafield(key: String!): String++ """+ Private metadata. Requires staff permissions to access. Use `keys` to control which fields you want to include. The default is to include everything.++ Added in Saleor 3.3.++ Note: this API is currently in Feature Preview and can be subject to changes at later point.+ """+ privateMetafields(keys: [String!]): Metadata++ """List of public metadata items. Can be accessed without permissions."""+ metadata: [MetadataItem!]!++ """+ A single key from public metadata.++ Tip: Use GraphQL aliases to fetch multiple keys.++ Added in Saleor 3.3.++ Note: this API is currently in Feature Preview and can be subject to changes at later point.+ """+ metafield(key: String!): String++ """+ Public metadata. Use `keys` to control which fields you want to include. The default is to include everything.++ Added in Saleor 3.3.++ Note: this API is currently in Feature Preview and can be subject to changes at later point.+ """+ metafields(keys: [String!]): Metadatavariant: ProductVariant!quantity: Int!@@ -8317,8 +8363,54 @@ type FulfillmentLine implements Node {}"""Represents order line of particular order."""-type OrderLine implements Node {+type OrderLine implements Node & ObjectWithMetadata {id: ID!++ """List of private metadata items. Requires staff permissions to access."""+ privateMetadata: [MetadataItem!]!++ """+ A single key from private metadata. Requires staff permissions to access.++ Tip: Use GraphQL aliases to fetch multiple keys.++ Added in Saleor 3.3.++ Note: this API is currently in Feature Preview and can be subject to changes at later point.+ """+ privateMetafield(key: String!): String++ """+ Private metadata. Requires staff permissions to access. Use `keys` to control which fields you want to include. The default is to include everything.++ Added in Saleor 3.3.++ Note: this API is currently in Feature Preview and can be subject to changes at later point.+ """+ privateMetafields(keys: [String!]): Metadata++ """List of public metadata items. Can be accessed without permissions."""+ metadata: [MetadataItem!]!++ """+ A single key from public metadata.++ Tip: Use GraphQL aliases to fetch multiple keys.++ Added in Saleor 3.3.++ Note: this API is currently in Feature Preview and can be subject to changes at later point.+ """+ metafield(key: String!): String++ """+ Public metadata. Use `keys` to control which fields you want to include. The default is to include everything.++ Added in Saleor 3.3.++ Note: this API is currently in Feature Preview and can be subject to changes at later point.+ """+ metafields(keys: [String!]): MetadataproductName: String!variantName: String!productSku: Stringdiff --git a/saleor/order/migrations/0154_auto_20220621_0850.py b/saleor/order/migrations/0154_auto_20220621_0850.pynew file mode 100644index 0000000000..5984fe1f07--- /dev/null+++ b/saleor/order/migrations/0154_auto_20220621_0850.py@@ -0,0 +1,47 @@+# Generated by Django 3.2.13 on 2022-06-21 08:50++import django.contrib.postgres.indexes+from django.db import migrations, models+import saleor.core.utils.json_serializer+++class Migration(migrations.Migration):++ dependencies = [+ ("order", "0153_merge_20220615_1232"),+ ]++ operations = [+ migrations.AddField(+ model_name="orderline",+ name="metadata",+ field=models.JSONField(+ blank=True,+ default=dict,+ encoder=saleor.core.utils.json_serializer.CustomJsonEncoder,+ null=True,+ ),+ ),+ migrations.AddField(+ model_name="orderline",+ name="private_metadata",+ field=models.JSONField(+ blank=True,+ default=dict,+ encoder=saleor.core.utils.json_serializer.CustomJsonEncoder,+ null=True,+ ),+ ),+ migrations.AddIndex(+ model_name="orderline",+ index=django.contrib.postgres.indexes.GinIndex(+ fields=["private_metadata"], name="orderline_p_meta_idx"+ ),+ ),+ migrations.AddIndex(+ model_name="orderline",+ index=django.contrib.postgres.indexes.GinIndex(+ fields=["metadata"], name="orderline_meta_idx"+ ),+ ),+ ]diff --git a/saleor/order/models.py b/saleor/order/models.pyindex 8b719d51b8..8d6e18b0e2 100644--- a/saleor/order/models.py+++ b/saleor/order/models.py@@ -446,7 +446,7 @@ class OrderLineQueryset(models.QuerySet):yield line-class OrderLine(models.Model):+class OrderLine(ModelWithMetadata):id = models.UUIDField(primary_key=True, editable=False, unique=True, default=uuid4)old_id = models.PositiveIntegerField(unique=True, null=True, blank=True)created_at = models.DateTimeField(auto_now_add=True)@@ -611,7 +611,7 @@ class OrderLine(models.Model):objects = models.Manager.from_queryset(OrderLineQueryset)()- class Meta:+ class Meta(ModelWithMetadata.Meta):ordering = ("created_at", "id")def __str__(self):