mirror of
https://github.com/inventree/InvenTree.git
synced 2025-04-29 20:16:44 +00:00
Rename field part.has_variants to part.is_template
This commit is contained in:
parent
c3d75deb16
commit
c45a506a10
19
InvenTree/build/migrations/0004_auto_20190525_2356.py
Normal file
19
InvenTree/build/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 = [
|
||||||
|
('build', '0003_auto_20190525_2355'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='build',
|
||||||
|
name='part',
|
||||||
|
field=models.ForeignKey(help_text='Select part to build', limit_choices_to={'active': True, 'buildable': True, 'is_template': False}, on_delete=django.db.models.deletion.CASCADE, related_name='builds', to='part.Part'),
|
||||||
|
),
|
||||||
|
]
|
@ -50,7 +50,7 @@ class Build(models.Model):
|
|||||||
part = models.ForeignKey('part.Part', on_delete=models.CASCADE,
|
part = models.ForeignKey('part.Part', on_delete=models.CASCADE,
|
||||||
related_name='builds',
|
related_name='builds',
|
||||||
limit_choices_to={
|
limit_choices_to={
|
||||||
'has_variants': False,
|
'is_template': False,
|
||||||
'buildable': True,
|
'buildable': True,
|
||||||
'active': True
|
'active': True
|
||||||
},
|
},
|
||||||
|
19
InvenTree/company/migrations/0005_auto_20190525_2356.py
Normal file
19
InvenTree/company/migrations/0005_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 = [
|
||||||
|
('company', '0004_auto_20190525_2354'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='supplierpart',
|
||||||
|
name='part',
|
||||||
|
field=models.ForeignKey(help_text='Select part', limit_choices_to={'is_template': False, 'purchaseable': True}, on_delete=django.db.models.deletion.CASCADE, related_name='supplier_parts', to='part.Part'),
|
||||||
|
),
|
||||||
|
]
|
@ -190,7 +190,7 @@ class SupplierPart(models.Model):
|
|||||||
related_name='supplier_parts',
|
related_name='supplier_parts',
|
||||||
limit_choices_to={
|
limit_choices_to={
|
||||||
'purchaseable': True,
|
'purchaseable': True,
|
||||||
'has_variants': False,
|
'is_template': False,
|
||||||
},
|
},
|
||||||
help_text='Select part',
|
help_text='Select part',
|
||||||
)
|
)
|
||||||
|
24
InvenTree/part/migrations/0004_auto_20190525_2356.py
Normal file
24
InvenTree/part/migrations/0004_auto_20190525_2356.py
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
# 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 = [
|
||||||
|
('part', '0003_auto_20190525_2226'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.RenameField(
|
||||||
|
model_name='part',
|
||||||
|
old_name='has_variants',
|
||||||
|
new_name='is_template',
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='part',
|
||||||
|
name='variant_of',
|
||||||
|
field=models.ForeignKey(blank=True, help_text='Is this part a variant of another part?', limit_choices_to={'active': True, 'is_template': True}, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='variants', to='part.Part'),
|
||||||
|
),
|
||||||
|
]
|
@ -192,7 +192,7 @@ class Part(models.Model):
|
|||||||
description: Longer form description of the part
|
description: Longer form description of the part
|
||||||
keywords: Optional keywords for improving part search results
|
keywords: Optional keywords for improving part search results
|
||||||
IPN: Internal part number (optional)
|
IPN: Internal part number (optional)
|
||||||
has_variants: If True, this part is a 'template' part and cannot be instantiated as a StockItem
|
is_template: If True, this part is a 'template' part and cannot be instantiated as a StockItem
|
||||||
URL: Link to an external page with more information about this part (e.g. internal Wiki)
|
URL: Link to an external page with more information about this part (e.g. internal Wiki)
|
||||||
image: Image of this part
|
image: Image of this part
|
||||||
default_location: Where the item is normally stored (may be null)
|
default_location: Where the item is normally stored (may be null)
|
||||||
@ -256,10 +256,10 @@ class Part(models.Model):
|
|||||||
def clean(self):
|
def clean(self):
|
||||||
""" Perform cleaning operations for the Part model """
|
""" Perform cleaning operations for the Part model """
|
||||||
|
|
||||||
if self.has_variants and self.variant_of is not None:
|
if self.is_template and self.variant_of is not None:
|
||||||
raise ValidationError({
|
raise ValidationError({
|
||||||
|
'is_template': _("Part cannot be a template part if it is a variant of another part"),
|
||||||
'variant_of': _("Part cannot be a variant of another part if it is already a template"),
|
'variant_of': _("Part cannot be a variant of another part if it is already a template"),
|
||||||
'has_variants': _("Part cannot be a template part if it is a variant of another part")
|
|
||||||
})
|
})
|
||||||
|
|
||||||
name = models.CharField(max_length=100, blank=False, help_text='Part name',
|
name = models.CharField(max_length=100, blank=False, help_text='Part name',
|
||||||
@ -268,12 +268,12 @@ class Part(models.Model):
|
|||||||
|
|
||||||
variant = models.CharField(max_length=32, blank=True, help_text='Part variant or revision code')
|
variant = models.CharField(max_length=32, blank=True, help_text='Part variant or revision code')
|
||||||
|
|
||||||
has_variants = models.BooleanField(default=False, help_text='Is this part a template part?')
|
is_template = models.BooleanField(default=False, help_text='Is this part a template part?')
|
||||||
|
|
||||||
variant_of = models.ForeignKey('part.Part', related_name='variants',
|
variant_of = models.ForeignKey('part.Part', related_name='variants',
|
||||||
null=True, blank=True,
|
null=True, blank=True,
|
||||||
limit_choices_to={
|
limit_choices_to={
|
||||||
'has_variants': True,
|
'is_template': True,
|
||||||
'active': True,
|
'active': True,
|
||||||
},
|
},
|
||||||
on_delete=models.SET_NULL,
|
on_delete=models.SET_NULL,
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
This part is not active:
|
This part is not active:
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if part.has_variants %}
|
{% if part.is_template %}
|
||||||
<div class='alert alert-info alert-block'>
|
<div class='alert alert-info alert-block'>
|
||||||
This part is a <i>template part</i>.<br>
|
This part is a <i>template part</i>.<br>
|
||||||
It is not a <i>real</i> part, but real parts can be based on this template.
|
It is not a <i>real</i> part, but real parts can be based on this template.
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
<li{% ifequal tab 'detail' %} class="active"{% endifequal %}>
|
<li{% ifequal tab 'detail' %} class="active"{% endifequal %}>
|
||||||
<a href="{% url 'part-detail' part.id %}">Details</a>
|
<a href="{% url 'part-detail' part.id %}">Details</a>
|
||||||
</li>
|
</li>
|
||||||
{% if part.has_variants %}
|
{% if part.is_template %}
|
||||||
<li{% ifequal tab 'variants' %} class='active'{% endifequal %}>
|
<li{% ifequal tab 'variants' %} class='active'{% endifequal %}>
|
||||||
<a href="{% url 'part-variants' part.id %}">Variants <span class='badge'>{{ part.variants.count }}</span></span></a>
|
<a href="{% url 'part-variants' part.id %}">Variants <span class='badge'>{{ part.variants.count }}</span></span></a>
|
||||||
</li>
|
</li>
|
||||||
@ -25,7 +25,7 @@
|
|||||||
<li{% ifequal tab 'used' %} class="active"{% endifequal %}>
|
<li{% ifequal tab 'used' %} class="active"{% endifequal %}>
|
||||||
<a href="{% url 'part-used-in' part.id %}">Used In{% if part.used_in_count > 0 %}<span class="badge">{{ part.used_in_count }}</span>{% endif %}</a></li>
|
<a href="{% url 'part-used-in' part.id %}">Used In{% if part.used_in_count > 0 %}<span class="badge">{{ part.used_in_count }}</span>{% endif %}</a></li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if part.purchaseable and part.has_variants == False %}
|
{% if part.purchaseable and part.is_template == False %}
|
||||||
<li{% ifequal tab 'suppliers' %} class="active"{% endifequal %}>
|
<li{% ifequal tab 'suppliers' %} class="active"{% endifequal %}>
|
||||||
<a href="{% url 'part-suppliers' part.id %}">Suppliers
|
<a href="{% url 'part-suppliers' part.id %}">Suppliers
|
||||||
<span class="badge">{{ part.supplier_count }}</span>
|
<span class="badge">{{ part.supplier_count }}</span>
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
<div id='button-toolbar'>
|
<div id='button-toolbar'>
|
||||||
<div class='btn-group'>
|
<div class='btn-group'>
|
||||||
{% if part.has_variants and part.active %}
|
{% if part.is_template and part.active %}
|
||||||
<button class='btn btn-success' id='new-variant' title='Create new variant'>New Variant</button>
|
<button class='btn btn-success' id='new-variant' title='Create new variant'>New Variant</button>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
@ -274,7 +274,7 @@ class StockList(generics.ListCreateAPIView):
|
|||||||
part = Part.objects.get(pk=part_id)
|
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 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)])
|
stock_list = stock_list.filter(part__in=[part.id for part in Part.objects.filter(variant_of=part_id)])
|
||||||
else:
|
else:
|
||||||
stock_list = stock_list.filter(part=part_id)
|
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
|
# A template part cannot be instantiated as a StockItem
|
||||||
if self.part.has_variants:
|
if self.part.is_template:
|
||||||
raise ValidationError({
|
raise ValidationError({
|
||||||
'part': _('Stock item cannot be created for a template Part')
|
'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,
|
part = models.ForeignKey('part.Part', on_delete=models.CASCADE,
|
||||||
related_name='stock_items', help_text='Base part',
|
related_name='stock_items', help_text='Base part',
|
||||||
limit_choices_to={
|
limit_choices_to={
|
||||||
'has_variants': False,
|
'is_template': False,
|
||||||
'active': True,
|
'active': True,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user