diff --git a/InvenTree/common/models.py b/InvenTree/common/models.py index b3a1c12e6d..9465d308a7 100644 --- a/InvenTree/common/models.py +++ b/InvenTree/common/models.py @@ -1775,7 +1775,7 @@ class InvenTreeSetting(BaseInvenTreeSetting): 'RETURNORDER_REFERENCE_PATTERN': { 'name': _('Return Order Reference Pattern'), 'description': _( - 'Required pattern for generating Return Order reference field' + 'Required pattern for generating Return Order referenfce field' ), 'default': 'RMA-{ref:04d}', 'validator': order.validators.validate_return_order_reference_pattern, @@ -2012,6 +2012,12 @@ class InvenTreeSetting(BaseInvenTreeSetting): 'default': False, 'validator': bool, }, + 'TEST_STATION_DATA': { + 'name': _('Enable Test Station Data'), + 'description': _('Enable test station data collection for test results'), + 'default': False, + 'validator': bool, + }, } typ = 'inventree' diff --git a/InvenTree/stock/serializers.py b/InvenTree/stock/serializers.py index 81baee7440..c0fc676945 100644 --- a/InvenTree/stock/serializers.py +++ b/InvenTree/stock/serializers.py @@ -144,6 +144,7 @@ class StockItemTestResultSerializer(InvenTree.serializers.InvenTreeModelSerializ started = data.get('started_datetime') finished = data.get('finished_datetime') + if started is not None and finished is not None and started > finished: raise ValidationError({ 'finished_datetime': _( diff --git a/InvenTree/stock/templates/stock/item.html b/InvenTree/stock/templates/stock/item.html index 0443e5eacc..33810b6da6 100644 --- a/InvenTree/stock/templates/stock/item.html +++ b/InvenTree/stock/templates/stock/item.html @@ -231,10 +231,13 @@ }); }); + {% settings_value "TEST_STATION_DATA" as test_station_fields %} + loadStockTestResultsTable( $("#test-result-table"), { part: {{ item.part.id }}, stock_item: {{ item.id }}, + test_station_fields: {% js_bool test_station_fields %} } ); diff --git a/InvenTree/templates/InvenTree/settings/stock.html b/InvenTree/templates/InvenTree/settings/stock.html index 39bdd51759..9ccca21af0 100644 --- a/InvenTree/templates/InvenTree/settings/stock.html +++ b/InvenTree/templates/InvenTree/settings/stock.html @@ -23,6 +23,7 @@ {% include "InvenTree/settings/setting.html" with key="STOCK_LOCATION_DEFAULT_ICON" icon="fa-icons" %} {% include "InvenTree/settings/setting.html" with key="STOCK_SHOW_INSTALLED_ITEMS" icon="fa-sitemap" %} {% include "InvenTree/settings/setting.html" with key="STOCK_ENFORCE_BOM_INSTALLATION" icon="fa-check-circle" %} + {% include "InvenTree/settings/setting.html" with key="TEST_STATION_DATA" icon="fa-network-wired" %} diff --git a/InvenTree/templates/js/translated/stock.js b/InvenTree/templates/js/translated/stock.js index 89dc953c00..5254eec00f 100644 --- a/InvenTree/templates/js/translated/stock.js +++ b/InvenTree/templates/js/translated/stock.js @@ -1685,8 +1685,12 @@ function loadStockTestResultsTable(table, options) { fields['stock_item']['value'] = options.stock_item; fields['template']['value'] = templateId; fields['template']['filters']['part'] = options.part; - fields['template']['started_datetime']['icon'] = 'fa-calendar-alt'; - fields['template']['finished_datetime']['icon'] = 'fa-calendar-alt'; + + if (!options.test_station_fields) { + delete fields['test_station']; + delete fields['started_datetime']; + delete fields['finished_datetime']; + } constructForm('{% url "api-stock-test-result-list" %}', { method: 'POST', diff --git a/src/frontend/src/pages/Index/Settings/SystemSettings.tsx b/src/frontend/src/pages/Index/Settings/SystemSettings.tsx index 26ea9f8c79..b2558461aa 100644 --- a/src/frontend/src/pages/Index/Settings/SystemSettings.tsx +++ b/src/frontend/src/pages/Index/Settings/SystemSettings.tsx @@ -213,7 +213,8 @@ export default function SystemSettings() { 'STOCK_OWNERSHIP_CONTROL', 'STOCK_LOCATION_DEFAULT_ICON', 'STOCK_SHOW_INSTALLED_ITEMS', - 'STOCK_ENFORCE_BOM_INSTALLATION' + 'STOCK_ENFORCE_BOM_INSTALLATION', + 'TEST_STATION_DATA' ]} /> )