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

@ -301,7 +301,6 @@ class MakePartVariant(AjaxCreateView):
form = super(AjaxCreateView, self).get_form()
# Hide some variant-related fields
form.fields['is_template'].widget = HiddenInput()
form.fields['variant_of'].widget = HiddenInput()
return form

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())

View File

@ -68,7 +68,7 @@ function loadStockTestResultsTable(table, options) {
html += makeIconButton('fa-plus icon-green', 'button-test-add', row.test_name, '{% trans "Add test result" %}');
if (!grouped) {
if (!grouped && row.result != null) {
var pk = row.pk;
html += makeIconButton('fa-edit icon-blue', 'button-test-edit', pk, '{% trans "Edit test result" %}');
html += makeIconButton('fa-trash-alt icon-red', 'button-test-delete', pk, '{% trans "Delete test result" %}');