Fixes: Order model orderproducts operations
This commit is contained in:
parent
578ec96603
commit
affe75c0af
1 changed files with 3 additions and 3 deletions
|
|
@ -590,7 +590,7 @@ class Order(ExportModelOperationsMixin("order"), NiceModel):
|
||||||
raise Http404(_(f"{name} does not exist: {product_uuid}"))
|
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):
|
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"))
|
raise ValueError(_("you cannot remove products from an order that is not a pending one"))
|
||||||
try:
|
try:
|
||||||
product = Product.objects.get(uuid=product_uuid)
|
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}>"))
|
raise Http404(_(f"{name} does not exist with query <{query}>"))
|
||||||
|
|
||||||
def remove_all_products(self):
|
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"))
|
raise ValueError(_("you cannot remove products from an order that is not a pending one"))
|
||||||
for order_product in self.order_products.all():
|
for order_product in self.order_products.all():
|
||||||
self.order_products.remove(order_product)
|
self.order_products.remove(order_product)
|
||||||
|
|
@ -622,7 +622,7 @@ class Order(ExportModelOperationsMixin("order"), NiceModel):
|
||||||
return self
|
return self
|
||||||
|
|
||||||
def remove_products_of_a_kind(self, product_uuid: str):
|
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"))
|
raise ValueError(_("you cannot remove products from an order that is not a pending one"))
|
||||||
try:
|
try:
|
||||||
product = Product.objects.get(uuid=product_uuid)
|
product = Product.objects.get(uuid=product_uuid)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue