2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-07-01 03:00:54 +00:00

Display testing status for a stock item

This commit is contained in:
Oliver Walters
2020-05-17 22:33:41 +10:00
parent 02b0c0831d
commit 1cc0977816
6 changed files with 19 additions and 9 deletions

View File

@ -1000,6 +1000,9 @@ class StockItem(MPTTModel):
'failed': failed,
}
def hasRequiredTests(self):
return self.part.getRequiredTests().count() > 0
def passedAllRequiredTests(self):
status = self.requiredTestStatus()

View File

@ -15,6 +15,12 @@ InvenTree | {% trans "Stock Item" %} - {{ item }}
{% block pre_content %}
{% include 'stock/loc_link.html' with location=item.location %}
{% if item.hasRequiredTests and not item.passedAllRequiredTests %}
<div class='alert alert-block alert-danger'>
{% trans "This stock item has not passed all required tests" %}
</div>
{% endif %}
{% for allocation in item.sales_order_allocations.all %}
<div class='alert alert-block alert-info'>
{% trans "This stock item is allocated to Sales Order" %} <a href="{% url 'so-detail' allocation.line.order.id %}"><b>#{{ allocation.line.order.reference }}</b></a> ({% trans "Quantity" %}: {% decimal allocation.quantity %})
@ -221,6 +227,13 @@ InvenTree | {% trans "Stock Item" %} - {{ item }}
<td>{% trans "Status" %}</td>
<td>{% stock_status_label item.status %}</td>
</tr>
{% if item.hasRequiredTests %}
<tr>
<td><span class='fas fa-vial'></span></td>
<td>{% trans "Tests" %}</td>
<td>{{ item.requiredTestStatus.passed }} / {{ item.requiredTestStatus.total }}</td>
</tr>
{% endif %}
</table>
{% endblock %}

View File

@ -36,7 +36,8 @@ loadStockTestResultsTable(
);
function reloadTable() {
$("#test-result-table").bootstrapTable("refresh");
location.reload();
//$("#test-result-table").bootstrapTable("refresh");
}
$("#add-test-result").click(function() {

View File

@ -456,11 +456,5 @@ class TestResultTest(StockTest):
test='sew cushion',
result=True
)
results = item.testResultMap()
for key in results.keys():
result = results[key]
self.assertTrue(item.passedAllRequiredTests())