mirror of
https://github.com/inventree/InvenTree.git
synced 2025-06-18 04:55:44 +00:00
Add a "completed" field to the Build model
- Keeps track of how many outputs have been produced - Will not be directly editable by the user
This commit is contained in:
24
InvenTree/build/migrations/0025_auto_20201020_1248.py
Normal file
24
InvenTree/build/migrations/0025_auto_20201020_1248.py
Normal file
@ -0,0 +1,24 @@
|
||||
# Generated by Django 3.0.7 on 2020-10-20 12:48
|
||||
|
||||
import django.core.validators
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('build', '0024_auto_20201020_1144'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='build',
|
||||
name='completed',
|
||||
field=models.PositiveIntegerField(default=0, help_text='Number of stock items which have been completed', verbose_name='Completed items'),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='build',
|
||||
name='quantity',
|
||||
field=models.PositiveIntegerField(default=1, help_text='Number of stock items to build', validators=[django.core.validators.MinValueValidator(1)], verbose_name='Build Quantity'),
|
||||
),
|
||||
]
|
@ -62,21 +62,6 @@ class Build(MPTTModel):
|
||||
|
||||
def get_absolute_url(self):
|
||||
return reverse('build-detail', kwargs={'pk': self.id})
|
||||
|
||||
def clean(self):
|
||||
"""
|
||||
Validation for Build object.
|
||||
"""
|
||||
|
||||
super().clean()
|
||||
|
||||
# Build quantity must be an integer
|
||||
# Maybe in the future this will be adjusted?
|
||||
|
||||
if not self.quantity == int(self.quantity):
|
||||
raise ValidationError({
|
||||
'quantity': _("Build quantity must be integer value for trackable parts")
|
||||
})
|
||||
|
||||
reference = models.CharField(
|
||||
unique=True,
|
||||
@ -149,7 +134,13 @@ class Build(MPTTModel):
|
||||
verbose_name=_('Build Quantity'),
|
||||
default=1,
|
||||
validators=[MinValueValidator(1)],
|
||||
help_text=_('Number of parts to build')
|
||||
help_text=_('Number of stock items to build')
|
||||
)
|
||||
|
||||
completed = models.PositiveIntegerField(
|
||||
verbose_name=_('Completed items'),
|
||||
default=0,
|
||||
help_text=_('Number of stock items which have been completed')
|
||||
)
|
||||
|
||||
status = models.PositiveIntegerField(
|
||||
|
@ -38,6 +38,7 @@ class BuildSerializer(InvenTreeModelSerializer):
|
||||
'url',
|
||||
'title',
|
||||
'creation_date',
|
||||
'completed',
|
||||
'completion_date',
|
||||
'part',
|
||||
'part_detail',
|
||||
@ -51,9 +52,10 @@ class BuildSerializer(InvenTreeModelSerializer):
|
||||
]
|
||||
|
||||
read_only_fields = [
|
||||
'status',
|
||||
'completed',
|
||||
'creation_date',
|
||||
'completion_data',
|
||||
'status',
|
||||
'status_text',
|
||||
]
|
||||
|
||||
|
@ -68,11 +68,6 @@ src="{% static 'img/blank_image.png' %}"
|
||||
|
||||
<h4>{% trans "Build Details" %}</h4>
|
||||
<table class='table table-striped table-condensed'>
|
||||
<tr>
|
||||
<td><span class='fas fa-hashtag'></span></td>
|
||||
<td>{% trans "Build Order Reference" %}</td>
|
||||
<td>{{ build }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><span class='fas fa-shapes'></span></td>
|
||||
<td>{% trans "Part" %}</td>
|
||||
@ -88,6 +83,11 @@ src="{% static 'img/blank_image.png' %}"
|
||||
<td>{% trans "Status" %}</td>
|
||||
<td>{% build_status_label build.status %}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><span class='fas fa-spinner'></span></td>
|
||||
<td>{% trans "Progress" %}</td>
|
||||
<td> {{ build.completed }} / {{ build.quantity }}</td>
|
||||
</tr>
|
||||
{% if build.parent %}
|
||||
<tr>
|
||||
<td><span class='fas fa-sitemap'></span></td>
|
||||
@ -102,20 +102,6 @@ src="{% static 'img/blank_image.png' %}"
|
||||
<td><a href="{% url 'so-detail' build.sales_order.id %}">{{ build.sales_order }}</a></td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
<tr>
|
||||
<td><span class='fas fa-dollar-sign'></span></td>
|
||||
<td>{% trans "BOM Price" %}</td>
|
||||
<td>
|
||||
{% if bom_price %}
|
||||
{{ bom_price }}
|
||||
{% if build.part.has_complete_bom_pricing == False %}
|
||||
<br><span class='warning-msg'><i>{% trans "BOM pricing is incomplete" %}</i></span>
|
||||
{% endif %}
|
||||
{% else %}
|
||||
<span class='warning-msg'><i>{% trans "No pricing information" %}</i></span>
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
{% endblock %}
|
||||
|
||||
|
@ -10,90 +10,133 @@
|
||||
|
||||
<hr>
|
||||
|
||||
<table class='table table-striped'>
|
||||
<col width='25'>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>{% trans "Title" %}</td>
|
||||
<td>{{ build.title }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><span class='fas fa-shapes'></span></td>
|
||||
<td>{% trans "Part" %}</td>
|
||||
<td><a href="{% url 'part-build' build.part.id %}">{{ build.part.full_name }}</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>{% trans "Quantity" %}</td><td>{{ build.quantity }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><span class='fas fa-map-marker-alt'></span></td>
|
||||
<td>{% trans "Stock Source" %}</td>
|
||||
<td>
|
||||
{% if build.take_from %}
|
||||
<a href="{% url 'stock-location-detail' build.take_from.id %}">{{ build.take_from }}</a>
|
||||
{% else %}
|
||||
<i>{% trans "Stock can be taken from any available location." %}</i>
|
||||
<div class='row'>
|
||||
<div class='col-sm-6'>
|
||||
<table class='table table-striped'>
|
||||
<col width='25'>
|
||||
<tr>
|
||||
<td><span class='fas fa-info'></span></td>
|
||||
<td>{% trans "Description" %}</td>
|
||||
<td>{{ build.title }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><span class='fas fa-shapes'></span></td>
|
||||
<td>{% trans "Part" %}</td>
|
||||
<td><a href="{% url 'part-build' build.part.id %}">{{ build.part.full_name }}</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>{% trans "Quantity" %}</td><td>{{ build.quantity }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><span class='fas fa-map-marker-alt'></span></td>
|
||||
<td>{% trans "Stock Source" %}</td>
|
||||
<td>
|
||||
{% if build.take_from %}
|
||||
<a href="{% url 'stock-location-detail' build.take_from.id %}">{{ build.take_from }}</a>
|
||||
{% else %}
|
||||
<i>{% trans "Stock can be taken from any available location." %}</i>
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><span class='fas fa-map-marker-alt'></span></td>
|
||||
<td>{% trans "Destination" %}</td>
|
||||
<td>
|
||||
{% if build.destination %}
|
||||
<a href="{% url 'stock-location-detail' build.destination.id %}">
|
||||
{{ build.destination }}
|
||||
</a>
|
||||
{% else %}
|
||||
<i>{% trans "Destination location not specified" %}</i>
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><span class='fas fa-info'></span></td>
|
||||
<td>{% trans "Status" %}</td>
|
||||
<td>{% build_status_label build.status %}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><span class='fas fa-spinner'></span></td>
|
||||
<td>{% trans "Progress" %}</td>
|
||||
<td>{{ build.completed }} / {{ build.quantity }}</td>
|
||||
</tr>
|
||||
{% if build.batch %}
|
||||
<tr>
|
||||
<td><span class='fas fa-layer-group'></span></td>
|
||||
<td>{% trans "Batch" %}</td>
|
||||
<td>{{ build.batch }}</td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><span class='fas fa-map-marker-alt'></span></td>
|
||||
<td>{% trans "Destination" %}</td>
|
||||
<td>
|
||||
{% if build.destination %}
|
||||
<a href="{% url 'stock-location-detail' build.destination.id %}">
|
||||
{{ build.destination }}
|
||||
</a>
|
||||
{% else %}
|
||||
<i>{% trans "Destination location not specified" %}</i>
|
||||
{% if build.parent %}
|
||||
<tr>
|
||||
<td><span class='fas fa-sitemap'></span></td>
|
||||
<td>{% trans "Parent Build" %}</td>
|
||||
<td><a href="{% url 'build-detail' build.parent.id %}">{{ build.parent }}</a></td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><span class='fas fa-info'></span></td>
|
||||
<td>{% trans "Status" %}</td>
|
||||
<td>{% build_status_label build.status %}</td>
|
||||
</tr>
|
||||
{% if build.batch %}
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>{% trans "Batch" %}</td>
|
||||
<td>{{ build.batch }}</td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
{% if build.link %}
|
||||
<tr>
|
||||
<td><span class='fas fa-link'></span></td>
|
||||
<td>{% trans "External Link" %}</td>
|
||||
<td><a href="{{ build.link }}">{{ build.link }}</a></td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
<tr>
|
||||
<td><span class='fas fa-calendar-alt'></span></td>
|
||||
<td>{% trans "Created" %}</td>
|
||||
<td>{{ build.creation_date }}</td>
|
||||
</tr>
|
||||
{% if build.is_active %}
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>{% trans "Enough Parts?" %}</td>
|
||||
<td>
|
||||
{% if build.can_build %}
|
||||
{% trans "Yes" %}
|
||||
{% else %}
|
||||
{% trans "No" %}
|
||||
{% if build.sales_order %}
|
||||
<tr>
|
||||
<td><span class='fas fa-dolly'></span></td>
|
||||
<td>{% trans "Sales Order" %}</td>
|
||||
<td><a href="{% url 'so-detail' build.sales_order.id %}">{{ build.sales_order }}</a></td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
{% if build.completion_date %}
|
||||
<tr>
|
||||
<td><span class='fas fa-calendar-alt'></span></td>
|
||||
<td>{% trans "Completed" %}</td>
|
||||
<td>{{ build.completion_date }}{% if build.completed_by %}<span class='badge'>{{ build.completed_by }}</span>{% endif %}</td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
</table>
|
||||
{% if build.link %}
|
||||
<tr>
|
||||
<td><span class='fas fa-link'></span></td>
|
||||
<td>{% trans "External Link" %}</td>
|
||||
<td><a href="{{ build.link }}">{{ build.link }}</a></td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
<tr>
|
||||
<td><span class='fas fa-calendar-alt'></span></td>
|
||||
<td>{% trans "Created" %}</td>
|
||||
<td>{{ build.creation_date }}</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<div class='col-sm-6'>
|
||||
<table class='table table-striped'>
|
||||
<col width='25'>
|
||||
<tr>
|
||||
<td><span class='fas fa-dollar-sign'></span></td>
|
||||
<td>{% trans "BOM Price" %}</td>
|
||||
<td>
|
||||
{% if bom_price %}
|
||||
{{ bom_price }}
|
||||
{% if build.part.has_complete_bom_pricing == False %}
|
||||
<br><span class='warning-msg'><i>{% trans "BOM pricing is incomplete" %}</i></span>
|
||||
{% endif %}
|
||||
{% else %}
|
||||
<span class='warning-msg'><i>{% trans "No pricing information" %}</i></span>
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
{% if build.is_active %}
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>{% trans "Enough Parts?" %}</td>
|
||||
<td>
|
||||
{% if build.can_build %}
|
||||
{% trans "Yes" %}
|
||||
{% else %}
|
||||
{% trans "No" %}
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
{% if build.completion_date %}
|
||||
<tr>
|
||||
<td><span class='fas fa-calendar-alt'></span></td>
|
||||
<td>{% trans "Completed" %}</td>
|
||||
<td>{{ build.completion_date }}{% if build.completed_by %}<span class='badge'>{{ build.completed_by }}</span>{% endif %}</td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% endblock %}
|
||||
|
Reference in New Issue
Block a user