diff --git a/InvenTree/build/migrations/0004_auto_20190525_2356.py b/InvenTree/build/migrations/0004_auto_20190525_2356.py new file mode 100644 index 0000000000..1a43e5bfc8 --- /dev/null +++ b/InvenTree/build/migrations/0004_auto_20190525_2356.py @@ -0,0 +1,19 @@ +# Generated by Django 2.2 on 2019-05-25 13:56 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('build', '0003_auto_20190525_2355'), + ] + + operations = [ + migrations.AlterField( + model_name='build', + name='part', + field=models.ForeignKey(help_text='Select part to build', limit_choices_to={'active': True, 'buildable': True, 'is_template': False}, on_delete=django.db.models.deletion.CASCADE, related_name='builds', to='part.Part'), + ), + ] diff --git a/InvenTree/build/models.py b/InvenTree/build/models.py index d01c001ba8..ad482b8dc6 100644 --- a/InvenTree/build/models.py +++ b/InvenTree/build/models.py @@ -50,7 +50,7 @@ class Build(models.Model): part = models.ForeignKey('part.Part', on_delete=models.CASCADE, related_name='builds', limit_choices_to={ - 'has_variants': False, + 'is_template': False, 'buildable': True, 'active': True }, diff --git a/InvenTree/company/migrations/0005_auto_20190525_2356.py b/InvenTree/company/migrations/0005_auto_20190525_2356.py new file mode 100644 index 0000000000..fe02be0d84 --- /dev/null +++ b/InvenTree/company/migrations/0005_auto_20190525_2356.py @@ -0,0 +1,19 @@ +# Generated by Django 2.2 on 2019-05-25 13:56 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('company', '0004_auto_20190525_2354'), + ] + + operations = [ + migrations.AlterField( + model_name='supplierpart', + name='part', + field=models.ForeignKey(help_text='Select part', limit_choices_to={'is_template': False, 'purchaseable': True}, on_delete=django.db.models.deletion.CASCADE, related_name='supplier_parts', to='part.Part'), + ), + ] diff --git a/InvenTree/company/models.py b/InvenTree/company/models.py index c62facb8ab..245264900d 100644 --- a/InvenTree/company/models.py +++ b/InvenTree/company/models.py @@ -190,7 +190,7 @@ class SupplierPart(models.Model): related_name='supplier_parts', limit_choices_to={ 'purchaseable': True, - 'has_variants': False, + 'is_template': False, }, help_text='Select part', ) diff --git a/InvenTree/part/migrations/0004_auto_20190525_2356.py b/InvenTree/part/migrations/0004_auto_20190525_2356.py new file mode 100644 index 0000000000..7b9a5fe6ac --- /dev/null +++ b/InvenTree/part/migrations/0004_auto_20190525_2356.py @@ -0,0 +1,24 @@ +# Generated by Django 2.2 on 2019-05-25 13:56 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('part', '0003_auto_20190525_2226'), + ] + + operations = [ + migrations.RenameField( + model_name='part', + old_name='has_variants', + new_name='is_template', + ), + migrations.AlterField( + model_name='part', + name='variant_of', + field=models.ForeignKey(blank=True, help_text='Is this part a variant of another part?', limit_choices_to={'active': True, 'is_template': True}, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='variants', to='part.Part'), + ), + ] diff --git a/InvenTree/part/models.py b/InvenTree/part/models.py index df948bb1c8..1511b7a0d8 100644 --- a/InvenTree/part/models.py +++ b/InvenTree/part/models.py @@ -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, diff --git a/InvenTree/part/templates/part/part_base.html b/InvenTree/part/templates/part/part_base.html index 42bbbbf8fd..748303df35 100644 --- a/InvenTree/part/templates/part/part_base.html +++ b/InvenTree/part/templates/part/part_base.html @@ -9,7 +9,7 @@ This part is not active: {% endif %} -{% if part.has_variants %} +{% if part.is_template %}