mirror of
https://github.com/inventree/InvenTree.git
synced 2025-04-30 04:26:44 +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:
|
else:
|
||||||
return static('/img/blank_image.png')
|
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):
|
def clean(self):
|
||||||
""" Perform cleaning operations for the Part model """
|
""" Perform cleaning operations for the Part model """
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user