2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-12-14 00:09:56 +00:00

Rename field part.has_variants to part.is_template

This commit is contained in:
Oliver Walters
2019-05-25 23:58:31 +10:00
parent c3d75deb16
commit c45a506a10
12 changed files with 95 additions and 14 deletions

View File

@@ -192,7 +192,7 @@ class Part(models.Model):
description: Longer form description of the part
keywords: Optional keywords for improving part search results
IPN: Internal part number (optional)
has_variants: If True, this part is a 'template' part and cannot be instantiated as a StockItem
is_template: If True, this part is a 'template' part and cannot be instantiated as a StockItem
URL: Link to an external page with more information about this part (e.g. internal Wiki)
image: Image of this part
default_location: Where the item is normally stored (may be null)
@@ -256,10 +256,10 @@ class Part(models.Model):
def clean(self):
""" Perform cleaning operations for the Part model """
if self.has_variants and self.variant_of is not None:
if self.is_template and self.variant_of is not None:
raise ValidationError({
'is_template': _("Part cannot be a template part if it is a variant of another part"),
'variant_of': _("Part cannot be a variant of another part if it is already a template"),
'has_variants': _("Part cannot be a template part if it is a variant of another part")
})
name = models.CharField(max_length=100, blank=False, help_text='Part name',
@@ -268,12 +268,12 @@ class Part(models.Model):
variant = models.CharField(max_length=32, blank=True, help_text='Part variant or revision code')
has_variants = models.BooleanField(default=False, help_text='Is this part a template part?')
is_template = models.BooleanField(default=False, help_text='Is this part a template part?')
variant_of = models.ForeignKey('part.Part', related_name='variants',
null=True, blank=True,
limit_choices_to={
'has_variants': True,
'is_template': True,
'active': True,
},
on_delete=models.SET_NULL,