Fixes validation error in models.py for adding discounts

This commit is contained in:
Christopher Neugebauer 2016-03-04 13:07:18 -08:00
parent a4de15830c
commit 99f4b8dfe0

View file

@ -149,7 +149,7 @@ class DiscountForProduct(models.Model):
cats = DiscountForCategory.objects.filter( cats = DiscountForCategory.objects.filter(
discount=self.discount, discount=self.discount,
category=self.product.category) category=self.product.category)
if len(prods) > 1 or self not in prods: if len(prods) > 1:
raise ValidationError( raise ValidationError(
_("You may only have one discount line per product")) _("You may only have one discount line per product"))
if len(cats) != 0: if len(cats) != 0:
@ -185,7 +185,7 @@ class DiscountForCategory(models.Model):
raise ValidationError( raise ValidationError(
_("You may only have one discount for " _("You may only have one discount for "
"a product or its category")) "a product or its category"))
if len(cats) > 1 or self not in cats: if len(cats) > 1:
raise ValidationError( raise ValidationError(
_("You may only have one discount line per category")) _("You may only have one discount line per category"))