mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Part name uniqueness is case insensitive
This commit is contained in:
parent
64d541f453
commit
219c438b82
@ -248,6 +248,18 @@ class Part(models.Model):
|
||||
else:
|
||||
return static('/img/blank_image.png')
|
||||
|
||||
def validate_unique(self, exclude=None):
|
||||
super().validate_unique(exclude)
|
||||
|
||||
# Part name uniqueness should be case insensitive
|
||||
try:
|
||||
if Part.objects.filter(name__iexact=self.name).exclude(id=self.id).exists():
|
||||
raise ValidationError({
|
||||
"name": _("A part with this name already exists")
|
||||
})
|
||||
except Part.DoesNotExist:
|
||||
pass
|
||||
|
||||
def clean(self):
|
||||
""" Perform cleaning operations for the Part model """
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user