[PUI] Test result fixes (#7956)

* Prevent template adjustment

* Prevent template from being edited

* Fix 'attachment' field for StockItemTestResultSerializer

- Allow 'null' value

* Bump API version
This commit is contained in:
Oliver 2024-08-22 13:50:04 +10:00 committed by GitHub
parent b0c7a1aed5
commit ca87df3c3d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 31 additions and 10 deletions

View File

@ -1,12 +1,15 @@
"""InvenTree API version information."""
# InvenTree API version
INVENTREE_API_VERSION = 246
INVENTREE_API_VERSION = 247
"""Increment this API version number whenever there is a significant change to the API that any clients need to know about."""
INVENTREE_API_TEXT = """
v247 - 2024-08-22 : https://github.com/inventree/InvenTree/pull/7956
- Adjust "attachment" field on StockItemTestResult serializer
- Allow null values for attachment
v246 - 2024-08-21 : https://github.com/inventree/InvenTree/pull/7862
- Adds custom status fields to various serializers

View File

@ -239,7 +239,10 @@ class StockItemTestResultSerializer(
)
attachment = InvenTree.serializers.InvenTreeAttachmentSerializerField(
required=False
required=False,
allow_null=True,
label=_('Attachment'),
help_text=_('Test result attachment'),
)
def validate(self, data):

View File

@ -922,10 +922,14 @@ export function stockLocationFields(): ApiFormFieldSet {
// Construct a set of fields for
export function useTestResultFields({
partId,
itemId
itemId,
templateId,
editTemplate = false
}: {
partId: number;
itemId: number;
templateId: number | undefined;
editTemplate?: boolean;
}): ApiFormFieldSet {
// Valid field choices
const [choices, setChoices] = useState<any[]>([]);
@ -947,6 +951,7 @@ export function useTestResultFields({
hidden: true
},
template: {
disabled: !editTemplate && !!templateId,
filters: {
include_inherited: true,
part: partId
@ -990,5 +995,13 @@ export function useTestResultFields({
hidden: !includeTestStation
}
};
}, [choices, fieldType, partId, itemId, includeTestStation]);
}, [
choices,
editTemplate,
fieldType,
partId,
itemId,
templateId,
includeTestStation
]);
}

View File

@ -67,7 +67,8 @@ export default function BuildOrderTestTable({
const testResultFields: ApiFormFieldSet = useTestResultFields({
partId: partId,
itemId: selectedOutput
itemId: selectedOutput,
templateId: selectedTemplate
});
const createTestResult = useCreateApiFormModal({

View File

@ -238,15 +238,16 @@ export default function StockItemTestResultTable({
];
}, [itemId]);
const resultFields: ApiFormFieldSet = useTestResultFields({
partId: partId,
itemId: itemId
});
const [selectedTemplate, setSelectedTemplate] = useState<number | undefined>(
undefined
);
const resultFields: ApiFormFieldSet = useTestResultFields({
partId: partId,
itemId: itemId,
templateId: selectedTemplate
});
const newTestModal = useCreateApiFormModal({
url: ApiEndpoints.stock_test_result_list,
fields: useMemo(() => ({ ...resultFields }), [resultFields]),