2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-07-06 05:30:56 +00:00

Logic fixes for CreateStockItem form

- Improved data validation
- Fix bug where form was not checked for validity
This commit is contained in:
Oliver Walters
2020-05-16 12:04:53 +10:00
parent 3d0bea15ae
commit 3df8f33080
2 changed files with 59 additions and 34 deletions

View File

@ -227,6 +227,18 @@ class StockItem(MPTTModel):
'status': 'Status cannot be marked as ASSIGNED_TO_OTHER_ITEM if the belongs_to field is not set',
})
if self.part.trackable:
# Trackable parts must have integer values for quantity field!
if not self.quantity == int(self.quantity):
raise ValidationError({
'quantity': _('Quantity must be integer value for trackable parts')
})
if self.quantity <= 0:
raise ValidationError({
'quantity': _('Quantity must be greater than zero')
})
# The 'supplier_part' field must point to the same part!
try:
if self.supplier_part is not None: