Skip to content

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

Handle warehouse without shipping zone in migrations

IKarbowiaka2d5871826d5
diff --git a/saleor/warehouse/migrations/0007_auto_20200406_0341.py b/saleor/warehouse/migrations/0007_auto_20200406_0341.py
index 631b75cb36..e414e51318 100644
--- a/saleor/warehouse/migrations/0007_auto_20200406_0341.py
+++ b/saleor/warehouse/migrations/0007_auto_20200406_0341.py
@@ -18,7 +18,10 @@ def create_allocations(apps, schema_editor):
OrderLine = apps.get_model("order", "OrderLine")
Warehouse = apps.get_model("warehouse", "Warehouse")
for warehouse in Warehouse.objects.iterator():
- shipping_zone_pk = warehouse.shipping_zones.first().pk
+ shipping_zone = warehouse.shipping_zones.first()
+ if not shipping_zone:
+ continue
+ shipping_zone_pk = shipping_zone.pk
for order_line in OrderLine.objects.filter(
order__shipping_method__shipping_zone__pk=shipping_zone_pk,
).iterator():