From 9bbcc35959f7ee7ffbfdc2fb8e6bef619df66607 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Sun, 5 May 2019 22:34:14 +1000 Subject: [PATCH] Builds can only be made for active parts --- .../migrations/0010_auto_20190505_2233.py | 19 +++++++++++++++++++ InvenTree/build/models.py | 5 ++++- 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 InvenTree/build/migrations/0010_auto_20190505_2233.py diff --git a/InvenTree/build/migrations/0010_auto_20190505_2233.py b/InvenTree/build/migrations/0010_auto_20190505_2233.py new file mode 100644 index 0000000000..5be6c393c9 --- /dev/null +++ b/InvenTree/build/migrations/0010_auto_20190505_2233.py @@ -0,0 +1,19 @@ +# Generated by Django 2.2 on 2019-05-05 12:33 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('build', '0009_build_completed_by'), + ] + + operations = [ + migrations.AlterField( + model_name='build', + name='part', + field=models.ForeignKey(limit_choices_to={'active': True, 'buildable': True}, 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 7175a18650..80feefc547 100644 --- a/InvenTree/build/models.py +++ b/InvenTree/build/models.py @@ -84,7 +84,10 @@ class Build(models.Model): part = models.ForeignKey('part.Part', on_delete=models.CASCADE, related_name='builds', - limit_choices_to={'buildable': True}, + limit_choices_to={ + 'buildable': True, + 'active': True + }, ) title = models.CharField(