Test result table fix (#6740)

* Fix stock.js

- Remove incorrect icon code

* Add TEST_STATION_DATA setting

- Controls whether test station fields are added

* Add setting to control test station fields

- Default to off to preserve old behaviour
This commit is contained in:
Oliver 2024-03-18 16:36:00 +11:00 committed by GitHub
parent 82654eabdc
commit 664063583f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 20 additions and 4 deletions

View File

@ -1775,7 +1775,7 @@ class InvenTreeSetting(BaseInvenTreeSetting):
'RETURNORDER_REFERENCE_PATTERN': { 'RETURNORDER_REFERENCE_PATTERN': {
'name': _('Return Order Reference Pattern'), 'name': _('Return Order Reference Pattern'),
'description': _( 'description': _(
'Required pattern for generating Return Order reference field' 'Required pattern for generating Return Order referenfce field'
), ),
'default': 'RMA-{ref:04d}', 'default': 'RMA-{ref:04d}',
'validator': order.validators.validate_return_order_reference_pattern, 'validator': order.validators.validate_return_order_reference_pattern,
@ -2012,6 +2012,12 @@ class InvenTreeSetting(BaseInvenTreeSetting):
'default': False, 'default': False,
'validator': bool, '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' typ = 'inventree'

View File

@ -144,6 +144,7 @@ class StockItemTestResultSerializer(InvenTree.serializers.InvenTreeModelSerializ
started = data.get('started_datetime') started = data.get('started_datetime')
finished = data.get('finished_datetime') finished = data.get('finished_datetime')
if started is not None and finished is not None and started > finished: if started is not None and finished is not None and started > finished:
raise ValidationError({ raise ValidationError({
'finished_datetime': _( 'finished_datetime': _(

View File

@ -231,10 +231,13 @@
}); });
}); });
{% settings_value "TEST_STATION_DATA" as test_station_fields %}
loadStockTestResultsTable( loadStockTestResultsTable(
$("#test-result-table"), { $("#test-result-table"), {
part: {{ item.part.id }}, part: {{ item.part.id }},
stock_item: {{ item.id }}, stock_item: {{ item.id }},
test_station_fields: {% js_bool test_station_fields %}
} }
); );

View File

@ -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_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_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="STOCK_ENFORCE_BOM_INSTALLATION" icon="fa-check-circle" %}
{% include "InvenTree/settings/setting.html" with key="TEST_STATION_DATA" icon="fa-network-wired" %}
</tbody> </tbody>
</table> </table>

View File

@ -1685,8 +1685,12 @@ function loadStockTestResultsTable(table, options) {
fields['stock_item']['value'] = options.stock_item; fields['stock_item']['value'] = options.stock_item;
fields['template']['value'] = templateId; fields['template']['value'] = templateId;
fields['template']['filters']['part'] = options.part; 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" %}', { constructForm('{% url "api-stock-test-result-list" %}', {
method: 'POST', method: 'POST',

View File

@ -213,7 +213,8 @@ export default function SystemSettings() {
'STOCK_OWNERSHIP_CONTROL', 'STOCK_OWNERSHIP_CONTROL',
'STOCK_LOCATION_DEFAULT_ICON', 'STOCK_LOCATION_DEFAULT_ICON',
'STOCK_SHOW_INSTALLED_ITEMS', 'STOCK_SHOW_INSTALLED_ITEMS',
'STOCK_ENFORCE_BOM_INSTALLATION' 'STOCK_ENFORCE_BOM_INSTALLATION',
'TEST_STATION_DATA'
]} ]}
/> />
) )