mirror of
https://github.com/inventree/InvenTree.git
synced 2025-04-28 11:36:44 +00:00
Handle ValueError when creating stock item (#5751)
This commit is contained in:
parent
e366cd1865
commit
d2a313bda9
@ -677,7 +677,11 @@ class StockList(APIDownloadMixin, ListCreateDestroyAPIView):
|
|||||||
if bool(data.get('use_pack_size')):
|
if bool(data.get('use_pack_size')):
|
||||||
quantity = data['quantity'] = supplier_part.base_quantity(quantity)
|
quantity = data['quantity'] = supplier_part.base_quantity(quantity)
|
||||||
# Divide purchase price by pack size, to save correct price per stock item
|
# 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
|
# Now remove the flag from data, so that it doesn't interfere with saving
|
||||||
# Do this regardless of results above
|
# Do this regardless of results above
|
||||||
|
Loading…
x
Reference in New Issue
Block a user