Skip to content

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

Fix orderline is_gift_card mutation (#8150)

Iga Karbowiak87e810710abc
diff --git a/saleor/order/migrations/0119_orderline_is_gift_card.py b/saleor/order/migrations/0119_orderline_is_gift_card.py
index 139cda97e7..c1f4fa80df 100644
--- a/saleor/order/migrations/0119_orderline_is_gift_card.py
+++ b/saleor/order/migrations/0119_orderline_is_gift_card.py
@@ -5,11 +5,13 @@ 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():
+ for line in OrderLine.objects.prefetch_related(
+ "variant__product__product_type"
+ ).iterator():
line.is_gift_card = (
- line.variant and line.variant.product.product_type.kind == "gift_card"
+ bool(line.variant) and line.variant.product.product_type.kind == "gift_card"
)
- line.save()
+ line.save(update_fields=["is_gift_card"])
class Migration(migrations.Migration):