diff --git a/InvenTree/part/api.py b/InvenTree/part/api.py index 46a15cfc62..27a5b24894 100644 --- a/InvenTree/part/api.py +++ b/InvenTree/part/api.py @@ -70,7 +70,7 @@ class CategoryDetail(generics.RetrieveUpdateDestroyAPIView): queryset = PartCategory.objects.all() -class PartDetail(generics.RetrieveUpdateDestroyAPIView): +class PartDetail(generics.RetrieveUpdateAPIView): """ API endpoint for detail view of a single Part object """ queryset = Part.objects.all() serializer_class = PartSerializer @@ -135,6 +135,7 @@ class PartList(generics.ListCreateAPIView): 'trackable', 'purchaseable', 'salable', + 'active', ] ordering_fields = [ diff --git a/InvenTree/part/migrations/0012_part_active.py b/InvenTree/part/migrations/0012_part_active.py new file mode 100644 index 0000000000..c2f3b55f6c --- /dev/null +++ b/InvenTree/part/migrations/0012_part_active.py @@ -0,0 +1,18 @@ +# Generated by Django 2.2 on 2019-04-28 13:00 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('part', '0011_auto_20190428_0841'), + ] + + operations = [ + migrations.AddField( + model_name='part', + name='active', + field=models.BooleanField(default=True, help_text='Is this part active?'), + ), + ] diff --git a/InvenTree/part/models.py b/InvenTree/part/models.py index 887c983511..04d5471f92 100644 --- a/InvenTree/part/models.py +++ b/InvenTree/part/models.py @@ -171,6 +171,9 @@ class Part(models.Model): # Can this part be sold to customers? salable = models.BooleanField(default=False, help_text="Can this part be sold to customers?") + # Is this part active? + active = models.BooleanField(default=True, help_text='Is this part active?') + notes = models.TextField(blank=True) def __str__(self): diff --git a/InvenTree/part/serializers.py b/InvenTree/part/serializers.py index 0344e46fe7..e5c23b730a 100644 --- a/InvenTree/part/serializers.py +++ b/InvenTree/part/serializers.py @@ -53,6 +53,7 @@ class PartSerializer(serializers.ModelSerializer): class Meta: model = Part + partial = True fields = [ 'pk', 'url', # Link to the part detail page @@ -70,6 +71,7 @@ class PartSerializer(serializers.ModelSerializer): 'consumable', 'trackable', 'salable', + 'active', ] diff --git a/InvenTree/part/templates/part/build.html b/InvenTree/part/templates/part/build.html index 999fe7e231..84642f4de8 100644 --- a/InvenTree/part/templates/part/build.html +++ b/InvenTree/part/templates/part/build.html @@ -7,7 +7,9 @@