From 41f8cf55b5f8831eabcde945c2bb231405ce81db Mon Sep 17 00:00:00 2001 From: Egor fureunoir Gorbunov Date: Thu, 22 May 2025 18:30:24 +0300 Subject: [PATCH] Features: 1) Allow skipping address validation for fully digital products; Fixes: 1) Correct improper logic when checking for missing addresses; Extra: 1) Minor structural improvement to conditional logic for clarity; --- core/models.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/core/models.py b/core/models.py index 1077a134..5ff8fa04 100644 --- a/core/models.py +++ b/core/models.py @@ -637,8 +637,11 @@ class Order(NiceModel): def apply_addresses(self, billing_address_uuid, shipping_address_uuid): try: - if not self.is_whole_digital and not any([shipping_address_uuid, billing_address_uuid]): - raise ValueError(_("you can only buy physical products with shipping address specified")) + if not any([shipping_address_uuid, billing_address_uuid]): + if self.is_whole_digital: + return + else: + raise ValueError(_("you can only buy physical products with shipping address specified")) if billing_address_uuid and not shipping_address_uuid: shipping_address = Address.objects.get(uuid=billing_address_uuid)