From 44e8ad630729567e64f8e7dab72c2fd087a42363 Mon Sep 17 00:00:00 2001 From: Egor fureunoir Gorbunov Date: Sat, 7 Jun 2025 17:26:41 +0300 Subject: [PATCH] Fixes: add_product for Order --- core/models.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/models.py b/core/models.py index 30a6ff03..f21b11f0 100644 --- a/core/models.py +++ b/core/models.py @@ -550,7 +550,7 @@ class Order(ExportModelOperationsMixin("order"), NiceModel): def total_quantity(self) -> int: return sum([op.quantity for op in self.order_products.all()]) - def add_product(self, product_uuid: str | None = None, attributes: list = list, update_quantity: bool = True): + def add_product(self, product_uuid: str | None = None, attributes: list = [], update_quantity: bool = True): if self.status not in ["PENDING", "MOMENTAL"]: raise ValueError(_("you cannot add products to an order that is not a pending one")) try: @@ -569,7 +569,7 @@ class Order(ExportModelOperationsMixin("order"), NiceModel): order_product, is_created = OrderProduct.objects.get_or_create( product=product, order=self, - attributes=json.dumps(attributes), + attributes=json.dumps(attributes) if attributes else {}, defaults={"quantity": 1, "buy_price": product.price}, ) if not is_created and update_quantity: