Skip to content

Commit

Permalink
Merge branch 'hotfix/TypeError_selfsale' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
Mael Lacour committed Dec 12, 2018
2 parents aa5b3dd + 2043f7b commit 796487e
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions modules/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,20 +78,21 @@ def form_valid(self, form):
shop=self.shop
)
for field in form.cleaned_data:
if field != 'client':
invoice = form.cleaned_data[field]
if invoice > 0 and isinstance(invoice, int):
if field != 'client' and form.cleaned_data[field] != '':
invoice = int(form.cleaned_data[field])
if invoice > 0:
try:
category_product = CategoryProduct.objects.get(
pk=field.split('-')[0])
except ObjectDoesNotExist:
pass
else:
SaleProduct.objects.create(
sale=sale,
product=category_product.product,
quantity=category_product.quantity * invoice,
price=category_product.get_price() * invoice
)
except ObjectDoesNotExist:
pass
sale.pay()
return sale_shop_module_resume(
self.request, sale, self.group, self.shop, self.module, self.success_url
Expand Down

0 comments on commit 796487e

Please sign in to comment.