From c2a35b6656bc3ecdc8465be114d067cf250ac344 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Sun, 28 Apr 2019 23:00:38 +1000 Subject: [PATCH 1/8] Add 'active' field to Part model --- InvenTree/part/migrations/0012_part_active.py | 18 ++++++++++++++++++ InvenTree/part/models.py | 3 +++ 2 files changed, 21 insertions(+) create mode 100644 InvenTree/part/migrations/0012_part_active.py 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): From 260d89005247d92250c0ea96062cd9c6c1715af4 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Sun, 28 Apr 2019 23:08:54 +1000 Subject: [PATCH 2/8] If a part is not active, display an INACTIVE Message on part page --- InvenTree/part/templates/part/part_base.html | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/InvenTree/part/templates/part/part_base.html b/InvenTree/part/templates/part/part_base.html index ceda740c16..79be275307 100644 --- a/InvenTree/part/templates/part/part_base.html +++ b/InvenTree/part/templates/part/part_base.html @@ -5,6 +5,11 @@ {% block content %}
+ {% if part.active == False %} +
+ This part ({{ part.name }}) is not active: +
+ {% endif %}
@@ -16,7 +21,7 @@ {% endif %}/>
-

{{ part.name }}

+

{{ part.name }}{% if part.active == False %} - INACTIVE{% endif %}

{% if part.description %}

{{ part.description }}

{% endif %} From 495d414d54b01a71206b4f891729c1944be663b9 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Sun, 28 Apr 2019 23:10:34 +1000 Subject: [PATCH 3/8] Hide some options if a part is not active --- InvenTree/part/templates/part/build.html | 2 ++ InvenTree/part/templates/part/detail.html | 7 ++++++- InvenTree/part/templates/part/stock.html | 2 ++ 3 files changed, 10 insertions(+), 1 deletion(-) 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 @@

Part Builds

+ {% if part.active %} + {% endif %}
diff --git a/InvenTree/part/templates/part/detail.html b/InvenTree/part/templates/part/detail.html index f0bdc49df2..2a8db4421a 100644 --- a/InvenTree/part/templates/part/detail.html +++ b/InvenTree/part/templates/part/detail.html @@ -17,7 +17,12 @@
  • Duplicate
  • Edit
  • Stocktake
  • -
  • Delete
  • +
    + {% if part.active %} +
  • Deactivate
  • + {% else %} +
  • Activate
  • + {% endif %} diff --git a/InvenTree/part/templates/part/stock.html b/InvenTree/part/templates/part/stock.html index a821652aae..fb620c1b7b 100644 --- a/InvenTree/part/templates/part/stock.html +++ b/InvenTree/part/templates/part/stock.html @@ -7,7 +7,9 @@

    Part Stock

    + {% if part.active %} + {% endif %}