From aa643f67737c4f317535e56fa0d536ad4841baea Mon Sep 17 00:00:00 2001 From: Egor fureunoir Gorbunov Date: Mon, 7 Jul 2025 19:49:44 +0300 Subject: [PATCH] Features: 1) Initialize `order.attributes` as an empty dictionary if undefined; Fixes: 1) Prevent potential errors when accessing `order.attributes` without initialization; Extra: None; --- core/models.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/core/models.py b/core/models.py index b09b4eaf..7fb82a04 100644 --- a/core/models.py +++ b/core/models.py @@ -1275,6 +1275,9 @@ class PromoCode(ExportModelOperationsMixin("promocode"), NiceModel): # type: ig if self.used_on: raise ValueError(_("promocode already used")) + if not order.attributes: + order.attributes = {} + promo_amount = order.total_price if self.discount_type == "percent":