mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Improve rendering of BuildComplete template
This commit is contained in:
parent
81f789d857
commit
50dbebdf59
@ -319,6 +319,30 @@ class Build(MPTTModel):
|
|||||||
self.status = BuildStatus.COMPLETE
|
self.status = BuildStatus.COMPLETE
|
||||||
self.save()
|
self.save()
|
||||||
|
|
||||||
|
def isFullyAllocated(self):
|
||||||
|
"""
|
||||||
|
Return True if this build has been fully allocated.
|
||||||
|
"""
|
||||||
|
|
||||||
|
bom_items = self.part.bom_items.all()
|
||||||
|
|
||||||
|
for item in bom_items:
|
||||||
|
part = item.sub_part
|
||||||
|
|
||||||
|
print("Checking:", part)
|
||||||
|
|
||||||
|
if not self.isPartFullyAllocated(part):
|
||||||
|
return False
|
||||||
|
|
||||||
|
return True
|
||||||
|
|
||||||
|
def isPartFullyAllocated(self, part):
|
||||||
|
"""
|
||||||
|
Check if a given Part is fully allocated for this Build
|
||||||
|
"""
|
||||||
|
|
||||||
|
return self.getAllocatedQuantity(part) >= self.getRequiredQuantity(part)
|
||||||
|
|
||||||
def getRequiredQuantity(self, part):
|
def getRequiredQuantity(self, part):
|
||||||
""" Calculate the quantity of <part> required to make this build.
|
""" Calculate the quantity of <part> required to make this build.
|
||||||
"""
|
"""
|
||||||
|
@ -1,42 +1,37 @@
|
|||||||
{% extends "modal_form.html" %}
|
{% extends "modal_form.html" %}
|
||||||
|
{% load i18n %}
|
||||||
|
|
||||||
{% block pre_form_content %}
|
{% block pre_form_content %}
|
||||||
<b>Build: {{ build.title }}</b> - {{ build.quantity }} x {{ build.part.full_name }}
|
|
||||||
<br>
|
|
||||||
Are you sure you want to mark this build as complete?
|
|
||||||
<hr>
|
|
||||||
{% if taking %}
|
|
||||||
The following items will be removed from stock:
|
|
||||||
|
|
||||||
<table class='table table-striped table-condensed'>
|
<h4>{% trans "Build" %} - {{ build }}</h4>
|
||||||
<tr>
|
|
||||||
<th></th>
|
{% if not build.isFullyAllocated %}
|
||||||
<th>Part</th>
|
<div class='alert alert-block alert-danger'>
|
||||||
<th>Quantity</th>
|
<h4>{% trans "Warning: Build order allocation is not complete" %}</h4>
|
||||||
<th>Location</th>
|
{% trans "Build Order has not been fully allocated. Ensure that all Stock Items have been allocated to the Build" %}
|
||||||
</tr>
|
</div>
|
||||||
{% for item in taking %}
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
{% include "hover_image.html" with image=item.stock_item.part.image hover=True %}
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
{{ item.stock_item.part.full_name }}<br>
|
|
||||||
<i>{{ item.stock_item.part.description }}</i>
|
|
||||||
</td>
|
|
||||||
<td>{{ item.quantity }}</td>
|
|
||||||
<td>{{ item.stock_item.location }}</td>
|
|
||||||
</tr>
|
|
||||||
{% endfor %}
|
|
||||||
</table>
|
|
||||||
{% else %}
|
{% else %}
|
||||||
No parts have been allocated to this build.
|
<div class='alert alert-block alert-info'>
|
||||||
|
<h4>{% trans "Build order allocation is complete" %}</h4>
|
||||||
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<hr>
|
|
||||||
The following items will be created:
|
<div class='alert alert-block alert-success'>
|
||||||
|
<h4>{% trans "The following actions will be performed:" %}</h4>
|
||||||
|
<ul>
|
||||||
|
<li>{% trans "Remove allocated items from stock" %}</li>
|
||||||
|
<li>{% trans "Add completed items to stock" %}</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class='panel panel-default'>
|
<div class='panel panel-default'>
|
||||||
|
<div class='panel-heading'>
|
||||||
|
{% trans "The following items will be created" %}
|
||||||
|
</div>
|
||||||
|
<div class='panel-content'>
|
||||||
{% include "hover_image.html" with image=build.part.image hover=True %}
|
{% include "hover_image.html" with image=build.part.image hover=True %}
|
||||||
{{ build.quantity }} x {{ build.part.full_name }}
|
{{ build.quantity }} x {{ build.part.full_name }}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
Loading…
Reference in New Issue
Block a user