mirror of
https://github.com/inventree/InvenTree.git
synced 2025-06-19 05:25:42 +00:00
Update 'Build'
- Part model now has active_builds and inactive_builds properties -
This commit is contained in:
@ -183,6 +183,28 @@ class Part(models.Model):
|
||||
|
||||
return total
|
||||
|
||||
@property
|
||||
def active_builds(self):
|
||||
""" Return a list of outstanding builds.
|
||||
Builds marked as 'complete' or 'cancelled' are ignored
|
||||
"""
|
||||
|
||||
return [b for b in self.builds.all() if b.is_active]
|
||||
|
||||
@property
|
||||
def inactive_builds(self):
|
||||
""" Return a list of inactive builds
|
||||
"""
|
||||
|
||||
return [b for b in self.builds.all() if not b.is_active]
|
||||
|
||||
@property
|
||||
def quantity_being_built(self):
|
||||
""" Return the current number of parts currently being built
|
||||
"""
|
||||
|
||||
return sum([b.quantity for b in self.active_builds])
|
||||
|
||||
@property
|
||||
def total_stock(self):
|
||||
""" Return the total stock quantity for this part.
|
||||
|
@ -4,10 +4,31 @@
|
||||
|
||||
{% include 'part/tabs.html' with tab='build' %}
|
||||
|
||||
<h3>Build Part</h3>
|
||||
<h3>Part Builds</h3>
|
||||
|
||||
TODO
|
||||
<br><br>
|
||||
You can build {{ part.can_build }} of this part with current stock.
|
||||
<table class='table table-striped'>
|
||||
|
||||
<tr>
|
||||
<th>Title</th>
|
||||
<th>Quantity</th>
|
||||
<th>Status</th>
|
||||
<th>Completion Date</th>
|
||||
</tr>
|
||||
{% if part.active_builds|length > 0 %}
|
||||
<tr>
|
||||
<td colspan="4"><b>Active Builds</b></td>
|
||||
</tr>
|
||||
{% include "part/build_list.html" with builds=part.active_builds %}
|
||||
{% endif %}
|
||||
|
||||
{% if part.inactive_builds|length > 0 %}
|
||||
<tr><td colspan="4"></td></tr>
|
||||
<tr>
|
||||
<td colspan="4"><b>Inactive Builds</b></td>
|
||||
</tr>
|
||||
{% include "part/build_list.html" with builds=part.inactive_builds %}
|
||||
{% endif %}
|
||||
|
||||
</table>
|
||||
|
||||
{% endblock %}
|
20
InvenTree/part/templates/part/build_list.html
Normal file
20
InvenTree/part/templates/part/build_list.html
Normal file
@ -0,0 +1,20 @@
|
||||
{% for build in builds %}
|
||||
<tr>
|
||||
<td><a href="{% url 'build-detail' build.id %}">{{ build.title }}</a></td>
|
||||
<td>{{ build.quantity }}</td>
|
||||
<td>
|
||||
{% if build.status == build.PENDING %}
|
||||
<span class='label label-info'>
|
||||
{% elif build.status == build.HOLDING %}
|
||||
<span class='label label-warning'>
|
||||
{% elif build.status == build.CANCELLED %}
|
||||
<span class='label label-danger'>
|
||||
{% elif build.status == build.COMPLETE %}
|
||||
<span class='label label-success'>
|
||||
{% endif %}
|
||||
{{ build.get_status_display }}
|
||||
</span>
|
||||
</td>
|
||||
<td>{{ build.completion_date }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
Reference in New Issue
Block a user