diff --git a/InvenTree/stock/models.py b/InvenTree/stock/models.py index 5400388e54..4b48e8138a 100644 --- a/InvenTree/stock/models.py +++ b/InvenTree/stock/models.py @@ -200,6 +200,13 @@ class StockItem(MPTTModel): super(StockItem, self).validate_unique(exclude) + # If the part is trackable, either serial number or batch number must be set + if self.part.trackable: + if not self.serial and not self.batch: + msg = _('Serial or batch number must be specified for trackable stock') + raise ValidationError(msg) + + # If the serial number is set, make sure it is not a duplicate if self.serial is not None: # Query to look for duplicate serial numbers parts = PartModels.Part.objects.filter(tree_id=self.part.tree_id) diff --git a/InvenTree/templates/stock_table.html b/InvenTree/templates/stock_table.html index b4b1b9d50f..dbf38ffe4e 100644 --- a/InvenTree/templates/stock_table.html +++ b/InvenTree/templates/stock_table.html @@ -3,25 +3,25 @@