diff --git a/InvenTree/part/migrations/0013_auto_20180414_2238.py b/InvenTree/part/migrations/0013_auto_20180414_2238.py new file mode 100644 index 0000000000..1184324c50 --- /dev/null +++ b/InvenTree/part/migrations/0013_auto_20180414_2238.py @@ -0,0 +1,24 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11 on 2018-04-14 22:38 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('part', '0012_auto_20180414_1032'), + ] + + operations = [ + migrations.AlterField( + model_name='part', + name='name', + field=models.CharField(max_length=100, unique=True), + ), + migrations.AlterUniqueTogether( + name='part', + unique_together=set([]), + ), + ] diff --git a/InvenTree/part/models.py b/InvenTree/part/models.py index 5b057f74c5..481859512a 100644 --- a/InvenTree/part/models.py +++ b/InvenTree/part/models.py @@ -77,12 +77,14 @@ class Part(models.Model): return '/part/{id}/'.format(id=self.id) # Short name of the part - name = models.CharField(max_length=100) + name = models.CharField(max_length=100, unique=True) # Longer description of the part (optional) description = models.CharField(max_length=250, blank=True) # Internal Part Number (optional) + # Potentially multiple parts map to the same internal IPN (variants?) + # So this does not have to be unique IPN = models.CharField(max_length=100, blank=True) # Provide a URL for an external link @@ -117,7 +119,7 @@ class Part(models.Model): class Meta: verbose_name = "Part" verbose_name_plural = "Parts" - unique_together = (("name", "category"),) + #unique_together = (("name", "category"),) @property def stock(self): diff --git a/InvenTree/part/templates/base.html b/InvenTree/part/templates/base.html index b788471be3..4d89b78c09 100644 --- a/InvenTree/part/templates/base.html +++ b/InvenTree/part/templates/base.html @@ -9,7 +9,8 @@ - + + @@ -31,7 +32,7 @@ InvenTree {% include "navbar.html" %} -
Deleting this part is a permanent action and cannot be undone.
+ + {% if part.usedInCount > 0 %} +This part is used in BOMs for {{ part.usedInCount }} other parts. If you delete this part, the BOMs for the following parts will be updated: +
There are {{ part.locations.all|length }} stock entries defined for this part. If you delete this part, the following stock entries will also be deleted: +
There are {{ part.supplier_parts.all|length }} suppliers defined for this part. If you delete this part, the following supplier parts will also be deleted. +
There are {{ part.serials.all|length }} unique parts tracked for '{{ part.name }}'. Deleting this part will permanently remove this tracking information.
+ {% endif %} + +