Features: 1) Initialize order.attributes as an empty dictionary if undefined;

Fixes: 1) Prevent potential errors when accessing `order.attributes` without initialization;

Extra: None;
This commit is contained in:
Egor Pavlovich Gorbunov 2025-07-07 19:49:44 +03:00
parent def55e9221
commit aa643f6773

View file

@ -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":