mirror of
https://github.com/inventree/InvenTree.git
synced 2025-06-14 19:15:41 +00:00
Rename field part.has_variants to part.is_template
This commit is contained in:
@ -274,7 +274,7 @@ class StockList(generics.ListCreateAPIView):
|
||||
part = Part.objects.get(pk=part_id)
|
||||
|
||||
# If the part is a Template part, select stock items for any "variant" parts under that template
|
||||
if part.has_variants:
|
||||
if part.is_template:
|
||||
stock_list = stock_list.filter(part__in=[part.id for part in Part.objects.filter(variant_of=part_id)])
|
||||
else:
|
||||
stock_list = stock_list.filter(part=part_id)
|
||||
|
19
InvenTree/stock/migrations/0004_auto_20190525_2356.py
Normal file
19
InvenTree/stock/migrations/0004_auto_20190525_2356.py
Normal file
@ -0,0 +1,19 @@
|
||||
# Generated by Django 2.2 on 2019-05-25 13:56
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('stock', '0003_auto_20190525_2303'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='stockitem',
|
||||
name='part',
|
||||
field=models.ForeignKey(help_text='Base part', limit_choices_to={'active': True, 'is_template': False}, on_delete=django.db.models.deletion.CASCADE, related_name='stock_items', to='part.Part'),
|
||||
),
|
||||
]
|
@ -159,7 +159,7 @@ class StockItem(models.Model):
|
||||
})
|
||||
|
||||
# A template part cannot be instantiated as a StockItem
|
||||
if self.part.has_variants:
|
||||
if self.part.is_template:
|
||||
raise ValidationError({
|
||||
'part': _('Stock item cannot be created for a template Part')
|
||||
})
|
||||
@ -213,7 +213,7 @@ class StockItem(models.Model):
|
||||
part = models.ForeignKey('part.Part', on_delete=models.CASCADE,
|
||||
related_name='stock_items', help_text='Base part',
|
||||
limit_choices_to={
|
||||
'has_variants': False,
|
||||
'is_template': False,
|
||||
'active': True,
|
||||
})
|
||||
|
||||
|
Reference in New Issue
Block a user