From affe75c0afe40e6d6f42d31eeeb020bbf6b1c119 Mon Sep 17 00:00:00 2001 From: Egor fureunoir Gorbunov Date: Sat, 7 Jun 2025 18:00:39 +0300 Subject: [PATCH] Fixes: Order model orderproducts operations --- core/models.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/models.py b/core/models.py index 4eb241e3..1b8bafce 100644 --- a/core/models.py +++ b/core/models.py @@ -590,7 +590,7 @@ class Order(ExportModelOperationsMixin("order"), NiceModel): raise Http404(_(f"{name} does not exist: {product_uuid}")) def remove_product(self, product_uuid: str | None = None, attributes: dict = dict, zero_quantity: bool = False): - if self.status != "PENDING": + if self.status not in ["PENDING", "MOMENTAL"]: raise ValueError(_("you cannot remove products from an order that is not a pending one")) try: product = Product.objects.get(uuid=product_uuid) @@ -614,7 +614,7 @@ class Order(ExportModelOperationsMixin("order"), NiceModel): raise Http404(_(f"{name} does not exist with query <{query}>")) def remove_all_products(self): - if self.status != "PENDING": + if self.status not in ["PENDING", "MOMENTAL"]: raise ValueError(_("you cannot remove products from an order that is not a pending one")) for order_product in self.order_products.all(): self.order_products.remove(order_product) @@ -622,7 +622,7 @@ class Order(ExportModelOperationsMixin("order"), NiceModel): return self def remove_products_of_a_kind(self, product_uuid: str): - if self.status != "PENDING": + if self.status not in ["PENDING", "MOMENTAL"]: raise ValueError(_("you cannot remove products from an order that is not a pending one")) try: product = Product.objects.get(uuid=product_uuid)