mirror of
https://github.com/inventree/InvenTree.git
synced 2025-06-19 21:45:39 +00:00
Rename field part.has_variants to part.is_template
This commit is contained in:
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
|
||||
keywords: Optional keywords for improving part search results
|
||||
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)
|
||||
image: Image of this part
|
||||
default_location: Where the item is normally stored (may be null)
|
||||
@ -256,10 +256,10 @@ class Part(models.Model):
|
||||
def clean(self):
|
||||
""" 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({
|
||||
'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"),
|
||||
'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',
|
||||
@ -268,12 +268,12 @@ class Part(models.Model):
|
||||
|
||||
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',
|
||||
null=True, blank=True,
|
||||
limit_choices_to={
|
||||
'has_variants': True,
|
||||
'is_template': True,
|
||||
'active': True,
|
||||
},
|
||||
on_delete=models.SET_NULL,
|
||||
|
@ -9,7 +9,7 @@
|
||||
This part is not active:
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if part.has_variants %}
|
||||
{% if part.is_template %}
|
||||
<div class='alert alert-info alert-block'>
|
||||
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.
|
||||
|
@ -2,7 +2,7 @@
|
||||
<li{% ifequal tab 'detail' %} class="active"{% endifequal %}>
|
||||
<a href="{% url 'part-detail' part.id %}">Details</a>
|
||||
</li>
|
||||
{% if part.has_variants %}
|
||||
{% if part.is_template %}
|
||||
<li{% ifequal tab 'variants' %} class='active'{% endifequal %}>
|
||||
<a href="{% url 'part-variants' part.id %}">Variants <span class='badge'>{{ part.variants.count }}</span></span></a>
|
||||
</li>
|
||||
@ -25,7 +25,7 @@
|
||||
<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>
|
||||
{% endif %}
|
||||
{% if part.purchaseable and part.has_variants == False %}
|
||||
{% if part.purchaseable and part.is_template == False %}
|
||||
<li{% ifequal tab 'suppliers' %} class="active"{% endifequal %}>
|
||||
<a href="{% url 'part-suppliers' part.id %}">Suppliers
|
||||
<span class="badge">{{ part.supplier_count }}</span>
|
||||
|
@ -15,7 +15,7 @@
|
||||
|
||||
<div id='button-toolbar'>
|
||||
<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>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
Reference in New Issue
Block a user