Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Simplify getting countries associated with warehouse
Mira Szewczyk616e542ee32b
diff --git a/saleor/warehouse/models.py b/saleor/warehouse/models.pyindex 38d6d57ff8..a8e0755d0b 100644--- a/saleor/warehouse/models.py+++ b/saleor/warehouse/models.py@@ -1,4 +1,5 @@import uuid+from typing import Setfrom django.db import modelsfrom django.utils.translation import pgettext_lazy@@ -46,6 +47,15 @@ class Warehouse(models.Model):def __str__(self):return self.name+ @property+ def countries(self) -> Set[str]:+ countries_zone = ",".join(+ ShippingZone.objects.prefetch_related("warehouse_set")+ .filter(warehouse=self)+ .values_list("countries", flat=True)+ )+ return set(countries_zone.split(","))+def delete(self, *args, **kwargs):self.address.delete()super().delete(*args, **kwargs)