Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Reduce voucher used counter when voucher is removed from order

Artur Smęt30b946ee9e60
diff --git a/saleor/dashboard/order/forms.py b/saleor/dashboard/order/forms.py
index d35f22a42c..392451af81 100644
--- a/saleor/dashboard/order/forms.py
+++ b/saleor/dashboard/order/forms.py
@@ -255,7 +255,6 @@ class CancelOrderForm(forms.Form):
group_form.cancel_group()
-
class RemoveVoucherForm(forms.Form):
def __init__(self, *args, **kwargs):
@@ -265,6 +264,9 @@ class RemoveVoucherForm(forms.Form):
def remove_voucher(self):
self.order.discount_amount = 0
self.order.discount_name = ''
+ voucher = self.order.voucher
+ voucher.used -= 1
+ voucher.save(update_fields=['used'])
self.order.voucher = None
self.order.recalculate()