Skip to content

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

Fix order_line.is_gift_card migration (#8144)

Iga Karbowiaka30a9c87eb38
diff --git a/saleor/order/migrations/0119_orderline_is_gift_card.py b/saleor/order/migrations/0119_orderline_is_gift_card.py
index 97d3d5062a..139cda97e7 100644
--- a/saleor/order/migrations/0119_orderline_is_gift_card.py
+++ b/saleor/order/migrations/0119_orderline_is_gift_card.py
@@ -6,7 +6,9 @@ from django.db import migrations, models
def set_is_gift_card_field(apps, schema_editor):
OrderLine = apps.get_model("order", "OrderLine")
for line in OrderLine.objects.iterator():
- line.is_gift_card = line.variant.product_type.kind == "gift_card"
+ line.is_gift_card = (
+ line.variant and line.variant.product.product_type.kind == "gift_card"
+ )
line.save()
@@ -14,6 +16,7 @@ class Migration(migrations.Migration):
dependencies = [
("order", "0118_auto_20210913_0731"),
+ ("product", "0148_producttype_type"),
]
operations = [