Skip to content

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

Disallow changing quantity of items in order line to 0

Marcin Gębalae9385472365c
diff --git a/saleor/dashboard/order/forms.py b/saleor/dashboard/order/forms.py
index 9acb74af9f..ecc660d7dd 100644
--- a/saleor/dashboard/order/forms.py
+++ b/saleor/dashboard/order/forms.py
@@ -46,7 +46,9 @@ class MoveItemsForm(forms.Form):
def __init__(self, *args, **kwargs):
self.item = kwargs.pop('item')
super(MoveItemsForm, self).__init__(*args, **kwargs)
- self.fields['how_many'].widget.attrs['max'] = self.item.quantity
+ self.fields['how_many'].widget.attrs.update({
+ 'max': self.item.quantity,
+ 'min': 1})
self.fields['groups'].choices = self.get_delivery_group_choices()
def get_delivery_group_choices(self):
@@ -85,7 +87,9 @@ class ChangeQuantityForm(forms.ModelForm):
def __init__(self, *args, **kwargs):
super(ChangeQuantityForm, self).__init__(*args, **kwargs)
self.initial_quantity = self.instance.quantity
- self.fields['quantity'].widget.attrs['max'] = self.instance.quantity
+ self.fields['quantity'].widget.attrs.update({
+ 'max': self.instance.quantity,
+ 'min': 1})
self.fields['quantity'].initial = self.initial_quantity
def get_variant(self):