Add default ordering for Company model

- Now will sort by "name" in choice fields, etc
This commit is contained in:
Oliver Walters 2020-08-08 16:54:09 +10:00
parent eac53c836c
commit ad977d4d26
2 changed files with 7 additions and 3 deletions

View File

@ -79,6 +79,9 @@ class Company(models.Model):
is_manufacturer: boolean value, is this company a manufacturer
"""
class Meta:
ordering = ['name',]
name = models.CharField(max_length=100, blank=False, unique=True,
help_text=_('Company name'),
verbose_name=_('Company name'))

View File

@ -71,8 +71,8 @@ class PartCategory(InvenTreeTree):
return reverse('category-detail', kwargs={'pk': self.id})
class Meta:
verbose_name = "Part Category"
verbose_name_plural = "Part Categories"
verbose_name = _("Part Category")
verbose_name_plural = _("Part Categories")
def get_parts(self, cascade=True):
""" Return a queryset for all parts under this category.
@ -239,6 +239,7 @@ class Part(MPTTModel):
class Meta:
verbose_name = _("Part")
verbose_name_plural = _("Parts")
ordering = ['name',]
class MPTTMeta:
# For legacy reasons the 'variant_of' field is used to indicate the MPTT parent
@ -1490,7 +1491,7 @@ class BomItem(models.Model):
pass
class Meta:
verbose_name = "BOM Item"
verbose_name = _("BOM Item")
# Prevent duplication of parent/child rows
unique_together = ('part', 'sub_part')