mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Handle case where calculation may be performed on invalid values (#5394)
This commit is contained in:
parent
73891f0b94
commit
54e0e47c6a
@ -677,8 +677,13 @@ class StockList(APIDownloadMixin, ListCreateDestroyAPIView):
|
||||
else:
|
||||
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)
|
||||
if data['purchase_price'] and supplier_part.pack_quantity_native:
|
||||
try:
|
||||
data['purchase_price'] = float(data['purchase_price']) / float(supplier_part.pack_quantity_native)
|
||||
except ValueError:
|
||||
pass
|
||||
|
||||
# Now remove the flag from data, so that it doesn't interfere with saving
|
||||
# Do this regardless of results above
|
||||
|
Loading…
Reference in New Issue
Block a user