From c3d75deb16f552f62a16c5a81d55b1eca0bd644a Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Sat, 25 May 2019 23:55:16 +1000 Subject: [PATCH] More 'limit_choices_to' limitations for template parts --- .../migrations/0003_auto_20190525_2355.py | 19 +++++++++++++++++++ InvenTree/build/models.py | 1 + .../migrations/0004_auto_20190525_2354.py | 19 +++++++++++++++++++ InvenTree/company/models.py | 5 ++++- 4 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 InvenTree/build/migrations/0003_auto_20190525_2355.py create mode 100644 InvenTree/company/migrations/0004_auto_20190525_2354.py diff --git a/InvenTree/build/migrations/0003_auto_20190525_2355.py b/InvenTree/build/migrations/0003_auto_20190525_2355.py new file mode 100644 index 0000000000..fe127061bc --- /dev/null +++ b/InvenTree/build/migrations/0003_auto_20190525_2355.py @@ -0,0 +1,19 @@ +# Generated by Django 2.2 on 2019-05-25 13:55 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('build', '0002_auto_20190520_2204'), + ] + + operations = [ + migrations.AlterField( + model_name='build', + name='part', + field=models.ForeignKey(help_text='Select part to build', limit_choices_to={'active': True, 'buildable': True, 'has_variants': 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 b5f5aa10eb..d01c001ba8 100644 --- a/InvenTree/build/models.py +++ b/InvenTree/build/models.py @@ -50,6 +50,7 @@ class Build(models.Model): part = models.ForeignKey('part.Part', on_delete=models.CASCADE, related_name='builds', limit_choices_to={ + 'has_variants': False, 'buildable': True, 'active': True }, diff --git a/InvenTree/company/migrations/0004_auto_20190525_2354.py b/InvenTree/company/migrations/0004_auto_20190525_2354.py new file mode 100644 index 0000000000..d402cdeed5 --- /dev/null +++ b/InvenTree/company/migrations/0004_auto_20190525_2354.py @@ -0,0 +1,19 @@ +# Generated by Django 2.2 on 2019-05-25 13:54 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('company', '0003_remove_supplierpart_minimum'), + ] + + operations = [ + migrations.AlterField( + model_name='supplierpart', + name='part', + field=models.ForeignKey(help_text='Select part', limit_choices_to={'has_variants': 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 be59c2b66f..c62facb8ab 100644 --- a/InvenTree/company/models.py +++ b/InvenTree/company/models.py @@ -188,7 +188,10 @@ class SupplierPart(models.Model): part = models.ForeignKey('part.Part', on_delete=models.CASCADE, related_name='supplier_parts', - limit_choices_to={'purchaseable': True}, + limit_choices_to={ + 'purchaseable': True, + 'has_variants': False, + }, help_text='Select part', )