Limit supplierpart part link to purchasable parts only

This commit is contained in:
Oliver Walters 2019-04-17 00:14:22 +10:00
parent cd0b6a6511
commit 5cd837be07
2 changed files with 22 additions and 1 deletions

View File

@ -0,0 +1,19 @@
# Generated by Django 2.2 on 2019-04-16 14:13
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('part', '0007_auto_20190417_0007'),
]
operations = [
migrations.AlterField(
model_name='supplierpart',
name='part',
field=models.ForeignKey(limit_choices_to={'purchasable': True}, on_delete=django.db.models.deletion.CASCADE, related_name='supplier_parts', to='part.Part'),
),
]

View File

@ -458,7 +458,9 @@ class SupplierPart(models.Model):
# Link to an actual part
# The part will have a field 'supplier_parts' which links to the supplier part options
part = models.ForeignKey(Part, on_delete=models.CASCADE,
related_name='supplier_parts')
related_name='supplier_parts',
limit_choices_to={'purchasable': True},
)
supplier = models.ForeignKey(Company, on_delete=models.CASCADE,
related_name='parts')