2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-07-03 04:00:57 +00:00

Changes to StockItem model

- Stock adjustments need to accept decimal values
This commit is contained in:
Oliver Walters
2019-11-19 09:18:41 +11:00
parent 20755a6dac
commit 75774771dc
2 changed files with 21 additions and 5 deletions

View File

@ -18,6 +18,7 @@ from django.dispatch import receiver
from mptt.models import TreeForeignKey
from decimal import Decimal, InvalidOperation
from datetime import datetime
from InvenTree import helpers
@ -549,7 +550,10 @@ class StockItem(models.Model):
quantity: If provided, override the quantity (default = total stock quantity)
"""
quantity = int(kwargs.get('quantity', self.quantity))
try:
quantity = Decimal(kwargs.get('quantity', self.quantity))
except InvalidOperation:
return False
if quantity <= 0:
return False
@ -618,7 +622,10 @@ class StockItem(models.Model):
record the date of stocktake
"""
count = int(count)
try:
count = Decimal(count)
except InvalidOperation:
return False
if count < 0 or self.infinite:
return False
@ -646,7 +653,10 @@ class StockItem(models.Model):
if self.serialized:
return False
quantity = int(quantity)
try:
quantity = Decimal(quantity)
except InvalidOperation:
return False
# Ignore amounts that do not make sense
if quantity <= 0 or self.infinite:
@ -670,7 +680,10 @@ class StockItem(models.Model):
if self.serialized:
return False
quantity = int(quantity)
try:
quantity = Decimal(quantity)
except InvalidOperation:
return False
if quantity <= 0 or self.infinite:
return False