From 53c5324df6e93b728af5f2d8d3c8479487890b20 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Mon, 9 Sep 2019 08:49:27 +1000 Subject: [PATCH] Fix uniqueness test for stock item --- InvenTree/stock/models.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/InvenTree/stock/models.py b/InvenTree/stock/models.py index e9220cabcb..c659801a0d 100644 --- a/InvenTree/stock/models.py +++ b/InvenTree/stock/models.py @@ -188,12 +188,12 @@ class StockItem(models.Model): if self.part.variant_of is not None: if StockItem.objects.filter(part__variant_of=self.part.variant_of, serial=self.serial).exclude(id=self.id).exists(): raise ValidationError({ - 'serial': _('A part with this serial number already exists for template part {part}'.format(part=self.part.variant_of)) + 'serial': _('A stock item with this serial number already exists for template part {part}'.format(part=self.part.variant_of)) }) else: - if StockItem.objects.filter(serial=self.serial).exclude(id=self.id).exists(): + if StockItem.objects.filter(part=self.part, serial=self.serial).exclude(id=self.id).exists(): raise ValidationError({ - 'serial': _('A part with this serial number already exists') + 'serial': _('A stock item with this serial number already exists') }) except Part.DoesNotExist: pass