Skip to content

Commit

Permalink
Handle ValueError when creating stock item (#5751)
Browse files Browse the repository at this point in the history
  • Loading branch information
SchrodingersGat committed Oct 19, 2023
1 parent e366cd1 commit d2a313b
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion InvenTree/stock/api.py
Expand Up @@ -677,7 +677,11 @@ def create(self, request, *args, **kwargs):
if bool(data.get('use_pack_size')):
quantity = data['quantity'] = supplier_part.base_quantity(quantity)
# Divide purchase price by pack size, to save correct price per stock item
data['purchase_price'] = float(data['purchase_price']) / float(supplier_part.pack_quantity_native)
try:
data['purchase_price'] = float(data['purchase_price']) / float(supplier_part.pack_quantity_native)
except ValueError:
# If the purchase price is not a number, ignore it
pass

# Now remove the flag from data, so that it doesn't interfere with saving
# Do this regardless of results above
Expand Down

0 comments on commit d2a313b

Please sign in to comment.