Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Fix validation bug
Michal Ociepkac08b7a022207
diff --git a/cart/__init__.py b/cart/__init__.pyindex 10062becff..03f3b9f742 100755--- a/cart/__init__.py+++ b/cart/__init__.py@@ -20,7 +20,7 @@ class Cart(cart.Cart):def __unicode__(self):return _('Cart (%(cart_count)s)' % {'cart_count': self.count()})- def check_quantity(self, product, quantity, replace=False):+ def check_quantity(self, product, quantity, data=None):if quantity > product.stock:raise InvalidQuantityException(_(u'Only %(total)s of product in stock.' % {@@ -29,7 +29,7 @@ class Cart(cart.Cart):product.stock - quantity)- return super(Cart, self).check_quantity(product, quantity, replace)+ return super(Cart, self).check_quantity(product, quantity, data)def get_default_currency(self):return settings.SATCHLESS_DEFAULT_CURRENCYdiff --git a/cart/forms.py b/cart/forms.pyindex 2d82da25b8..f30431358c 100644--- a/cart/forms.py+++ b/cart/forms.py@@ -23,9 +23,10 @@ class AddToCartForm(forms.Form):def clean_quantity(self):quantity = self.cleaned_data['quantity']try:- self.cart.check_quantity(self.product, quantity)+ self.cart.check_quantity(self.product,+ quantity + self.product.stock)except InvalidQuantityException as e:- raise forms.ValidationError(e.reason)+ raise forms.ValidationError(e)return quantity