diff --git a/InvenTree/stock/templates/stock/item_tests.html b/InvenTree/stock/templates/stock/item_tests.html
index e9835f6071..9172bfdde4 100644
--- a/InvenTree/stock/templates/stock/item_tests.html
+++ b/InvenTree/stock/templates/stock/item_tests.html
@@ -10,11 +10,30 @@
{% trans "Test Results" %}
-
+
+
+
{% endblock %}
{% block js_ready %}
{{ block.super }}
+loadStockTestResultsTable(
+ $("#test-result-table"), {
+ params: {
+ stock_item: {{ item.id }},
+ user_detail: true,
+ attachment_detail: true,
+ },
+ }
+);
+
{% endblock %}
\ No newline at end of file
diff --git a/InvenTree/templates/js/stock.html b/InvenTree/templates/js/stock.html
index 386ac16bad..48d6cae6e0 100644
--- a/InvenTree/templates/js/stock.html
+++ b/InvenTree/templates/js/stock.html
@@ -18,6 +18,110 @@ function removeStockRow(e) {
$('#' + row).remove();
}
+
+function passFailBadge(result) {
+
+ if (result) {
+ return `{% trans "PASS" %}`;
+ } else {
+ return `{% trans "FAIL" %}`;
+ }
+}
+
+function loadStockTestResultsTable(table, options) {
+ /*
+ * Load StockItemTestResult table
+ */
+
+ var params = options.params || {};
+
+ // HTML element to setup the filtering
+ var filterListElement = options.filterList || '#filter-list-stocktests';
+
+ var filters = {};
+
+ filters = loadTableFilters("stocktests");
+
+ var original = {};
+
+ for (var key in params) {
+ original[key] = params[key];
+ }
+
+ setupFilterList("stocktests", table, filterListElement);
+
+ // Override the default values, or add new ones
+ for (var key in params) {
+ filters[key] = params[key];
+ }
+
+ table.inventreeTable({
+ method: 'get',
+ formatNoMatches: function() {
+ return '{% trans "No test results matching query" %}';
+ },
+ url: "{% url 'api-stock-test-result-list' %}",
+ queryParams: filters,
+ original: original,
+ columns: [
+ {
+ field: 'pk',
+ title: 'ID',
+ visible: false
+ },
+ {
+ field: 'test',
+ title: '{% trans "Test" %}',
+ sortable: true,
+ formatter: function(value, row) {
+ var html = value;
+
+ if (row.attachment_detail) {
+ html += ``;
+ }
+
+ return html;
+ },
+ },
+ {
+ field: 'result',
+ title: "{% trans "Result" %}",
+ sortable: true,
+ formatter: function(value) {
+ return passFailBadge(value);
+ }
+ },
+ {
+ field: 'value',
+ title: "{% trans "Value" %}",
+ sortable: true,
+ },
+ {
+ field: 'notes',
+ title: '{% trans "Notes" %}',
+ },
+ {
+ field: 'date',
+ title: '{% trans "Uploaded" %}',
+ sortable: true,
+ formatter: function(value, row) {
+ var html = value;
+
+ if (row.user_detail) {
+ html += `${row.user_detail.username}`;
+ }
+
+ return html;
+ }
+ },
+ {
+ field: 'buttons',
+ },
+ ]
+ });
+}
+
+
function loadStockTable(table, options) {
/* Load data into a stock table with adjustable options.
* Fetches data (via AJAX) and loads into a bootstrap table.
diff --git a/InvenTree/templates/js/table_filters.html b/InvenTree/templates/js/table_filters.html
index efee6d221f..955703a7c9 100644
--- a/InvenTree/templates/js/table_filters.html
+++ b/InvenTree/templates/js/table_filters.html
@@ -37,6 +37,16 @@ function getAvailableTableFilters(tableKey) {
};
}
+ // Filters for the 'stock test' table
+ if (tableKey == 'stocktests') {
+ return {
+ result: {
+ type: 'bool',
+ title: "{% trans 'Test result' %}",
+ },
+ }
+ }
+
// Filters for the "Build" table
if (tableKey == 'build') {
return {