mirror of
https://github.com/inventree/InvenTree.git
synced 2025-04-28 11:36:44 +00:00
Merge pull request #492 from SchrodingersGat/fix
Fix uniqueness test for stock item
This commit is contained in:
commit
f5e34bef7e
@ -188,12 +188,12 @@ class StockItem(models.Model):
|
|||||||
if self.part.variant_of is not None:
|
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():
|
if StockItem.objects.filter(part__variant_of=self.part.variant_of, serial=self.serial).exclude(id=self.id).exists():
|
||||||
raise ValidationError({
|
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:
|
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({
|
raise ValidationError({
|
||||||
'serial': _('A part with this serial number already exists')
|
'serial': _('A stock item with this serial number already exists')
|
||||||
})
|
})
|
||||||
except Part.DoesNotExist:
|
except Part.DoesNotExist:
|
||||||
pass
|
pass
|
||||||
|
Loading…
x
Reference in New Issue
Block a user