Integrate Deutsche Post shipping API and models

Added Deutsche Post as a shipping carrier, including new models, admin, serializers, and API client integration. Updated Carrier and SiteConfiguration models to support Deutsche Post, including shipping price and API credentials. Added requirements for the Deutsche Post API client and dependencies.
This commit is contained in:
2026-01-11 16:32:51 +01:00
parent 7ebc83dd8c
commit 2213e115c6
131 changed files with 14686 additions and 5 deletions

View File

@@ -53,7 +53,6 @@ class Product(models.Model):
"self",
symmetrical=True,
blank=True,
related_name="variant_of",
help_text=(
"Symetrické varianty produktu: pokud přidáte variantu A → B, "
"Django automaticky přidá i variantu B → A. "
@@ -208,6 +207,7 @@ class Order(models.Model):
class Carrier(models.Model):
class SHIPPING(models.TextChoices):
ZASILKOVNA = "packeta", "cz#Zásilkovna"
DEUTSCHEPOST = "deutschepost", "cz#Deutsche Post"
STORE = "store", "cz#Osobní odběr"
shipping_method = models.CharField(max_length=20, choices=SHIPPING.choices, default=SHIPPING.STORE)
@@ -223,6 +223,11 @@ class Carrier(models.Model):
zasilkovna = models.ManyToManyField(
ZasilkovnaPacket, blank=True, related_name="carriers"
)
# Deutsche Post integration (same pattern as zasilkovna)
deutschepost = models.ManyToManyField(
"deutschepost.DeutschePostOrder", blank=True, related_name="carriers"
)
weight = models.DecimalField(max_digits=10, decimal_places=2, null=True, blank=True, help_text="Hmotnost zásilky v kg")
@@ -241,6 +246,8 @@ class Carrier(models.Model):
def get_price(self):
if self.shipping_method == self.SHIPPING.ZASILKOVNA:
return SiteConfiguration.get_solo().zasilkovna_shipping_price
elif self.shipping_method == self.SHIPPING.DEUTSCHEPOST:
return SiteConfiguration.get_solo().deutschepost_shipping_price
else:
return Decimal('0.0')
@@ -255,6 +262,19 @@ class Carrier(models.Model):
notify_zasilkovna_sended.delay(order=self.orders.first(), user=self.orders.first().user)
elif self.shipping_method == self.SHIPPING.DEUTSCHEPOST:
# Import here to avoid circular imports
from thirdparty.deutschepost.models import DeutschePostOrder
# Create new Deutsche Post order and add to carrier (same pattern as zasilkovna)
dp_order = DeutschePostOrder.objects.create()
self.deutschepost.add(dp_order)
self.returning = False
self.save()
# Order shipping through Deutsche Post API
dp_order.order_shippment()
elif self.shipping_method == self.SHIPPING.STORE:
self.state = self.STATE.READY_TO_PICKUP
self.save()