diff --git a/InvenTree/part/api.py b/InvenTree/part/api.py index f50dc0aef8..500b4a2bdf 100644 --- a/InvenTree/part/api.py +++ b/InvenTree/part/api.py @@ -127,6 +127,8 @@ class PartList(generics.ListCreateAPIView): ] filter_fields = [ + 'is_template', + 'variant_of', 'buildable', 'consumable', 'trackable', diff --git a/InvenTree/part/forms.py b/InvenTree/part/forms.py index cbc1cdaf8c..a2ec613429 100644 --- a/InvenTree/part/forms.py +++ b/InvenTree/part/forms.py @@ -92,7 +92,6 @@ class EditPartForm(HelperForm): 'category', 'name', 'IPN', - 'variant', 'is_template', 'variant_of', 'description', diff --git a/InvenTree/part/migrations/0005_auto_20190526_1119.py b/InvenTree/part/migrations/0005_auto_20190526_1119.py new file mode 100644 index 0000000000..36d55188f0 --- /dev/null +++ b/InvenTree/part/migrations/0005_auto_20190526_1119.py @@ -0,0 +1,26 @@ +# Generated by Django 2.2 on 2019-05-26 01:19 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('part', '0004_auto_20190525_2356'), + ] + + operations = [ + migrations.AddField( + model_name='part', + name='revision', + field=models.CharField(blank=True, help_text='Part rerevision code', max_length=32), + ), + migrations.AlterUniqueTogether( + name='part', + unique_together={('name', 'revision')}, + ), + migrations.RemoveField( + model_name='part', + name='variant', + ), + ] diff --git a/InvenTree/part/migrations/0006_auto_20190526_1215.py b/InvenTree/part/migrations/0006_auto_20190526_1215.py new file mode 100644 index 0000000000..b91cc8bbab --- /dev/null +++ b/InvenTree/part/migrations/0006_auto_20190526_1215.py @@ -0,0 +1,27 @@ +# Generated by Django 2.2 on 2019-05-26 02:15 + +import InvenTree.validators +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('part', '0005_auto_20190526_1119'), + ] + + operations = [ + migrations.AlterField( + model_name='part', + name='name', + field=models.CharField(help_text='Part name (must be unique)', max_length=100, unique=True, validators=[InvenTree.validators.validate_part_name]), + ), + migrations.AlterUniqueTogether( + name='part', + unique_together=set(), + ), + migrations.RemoveField( + model_name='part', + name='revision', + ), + ] diff --git a/InvenTree/part/models.py b/InvenTree/part/models.py index 3b9a7aea60..048330c2c6 100644 --- a/InvenTree/part/models.py +++ b/InvenTree/part/models.py @@ -162,6 +162,7 @@ def match_part_names(match, threshold=80, reverse=True, compare_length=False): if compare_length: # Also employ primitive length comparison + # TODO - Improve this somewhat... l_min = min(len(match), len(compare)) l_max = max(len(match), len(compare)) @@ -211,9 +212,6 @@ class Part(models.Model): class Meta: verbose_name = "Part" verbose_name_plural = "Parts" - unique_together = [ - ('name', 'variant') - ] def __str__(self): return "{n} - {d}".format(n=self.full_name, d=self.description) @@ -236,9 +234,6 @@ class Part(models.Model): elements.append(self.name) - if self.variant: - elements.append(self.variant) - return ' | '.join(elements) def get_absolute_url(self): @@ -262,12 +257,11 @@ class Part(models.Model): 'variant_of': _("Part cannot be a variant of another part if it is already a template"), }) - name = models.CharField(max_length=100, blank=False, help_text='Part name', + name = models.CharField(max_length=100, blank=False, unique=True, + help_text='Part name (must be unique)', validators=[validators.validate_part_name] ) - variant = models.CharField(max_length=32, blank=True, help_text='Part variant or revision code') - is_template = models.BooleanField(default=False, help_text='Is this part a template part?') variant_of = models.ForeignKey('part.Part', related_name='variants', diff --git a/InvenTree/part/serializers.py b/InvenTree/part/serializers.py index 540f754765..fe858091c7 100644 --- a/InvenTree/part/serializers.py +++ b/InvenTree/part/serializers.py @@ -87,7 +87,6 @@ class PartSerializer(serializers.ModelSerializer): 'IPN', 'is_template', 'variant_of', - 'variant', 'description', 'keywords', 'URL', diff --git a/InvenTree/part/templates/part/detail.html b/InvenTree/part/templates/part/detail.html index 068731da64..9765a2574e 100644 --- a/InvenTree/part/templates/part/detail.html +++ b/InvenTree/part/templates/part/detail.html @@ -42,12 +42,6 @@
Variant: {{ part.variant }}
- {% endif %}{{ part.description }}