From 2478b08a605b11051f4c61e3e019c7e7c4ed1919 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Wed, 26 Nov 2025 00:27:14 +0000 Subject: [PATCH] Fix for Category Parameters --- src/backend/InvenTree/part/api.py | 2 +- src/backend/InvenTree/part/serializers.py | 23 ++++++++++++------- .../tables/part/PartCategoryTemplateTable.tsx | 12 ++++++---- 3 files changed, 23 insertions(+), 14 deletions(-) diff --git a/src/backend/InvenTree/part/api.py b/src/backend/InvenTree/part/api.py index b700fafd22..b161e0114c 100644 --- a/src/backend/InvenTree/part/api.py +++ b/src/backend/InvenTree/part/api.py @@ -318,7 +318,7 @@ class CategoryTree(ListAPI): return queryset -class CategoryParameterList(DataExportViewMixin, ListCreateAPI): +class CategoryParameterList(DataExportViewMixin, OutputOptionsMixin, ListCreateAPI): """API endpoint for accessing a list of PartCategoryParameterTemplate objects. - GET: Return a list of PartCategoryParameterTemplate objects diff --git a/src/backend/InvenTree/part/serializers.py b/src/backend/InvenTree/part/serializers.py index e442d931ee..8a9d1e1acb 100644 --- a/src/backend/InvenTree/part/serializers.py +++ b/src/backend/InvenTree/part/serializers.py @@ -1745,7 +1745,9 @@ class BomItemSerializer( @register_importer() class CategoryParameterTemplateSerializer( - DataImportExportSerializerMixin, InvenTree.serializers.InvenTreeModelSerializer + InvenTree.serializers.FilterableSerializerMixin, + DataImportExportSerializerMixin, + InvenTree.serializers.InvenTreeModelSerializer, ): """Serializer for the PartCategoryParameterTemplate model.""" @@ -1758,17 +1760,22 @@ class CategoryParameterTemplateSerializer( 'category', 'category_detail', 'template', - # 'parameter_template_detail', + 'template_detail', 'default_value', ] - # TODO: Re-implement this, but point to the ParameterTemplate model - # parameter_template_detail = PartParameterTemplateSerializer( - # source='parameter_template', many=False, read_only=True - # ) + template_detail = enable_filter( + common.serializers.ParameterTemplateSerializer( + source='template', many=False, read_only=True + ), + True, + ) - category_detail = CategorySerializer( - source='category', many=False, read_only=True, allow_null=True + category_detail = enable_filter( + CategorySerializer( + source='category', many=False, read_only=True, allow_null=True + ), + True, ) diff --git a/src/frontend/src/tables/part/PartCategoryTemplateTable.tsx b/src/frontend/src/tables/part/PartCategoryTemplateTable.tsx index 6d705afbce..604e18609a 100644 --- a/src/frontend/src/tables/part/PartCategoryTemplateTable.tsx +++ b/src/frontend/src/tables/part/PartCategoryTemplateTable.tsx @@ -37,7 +37,7 @@ export default function PartCategoryTemplateTable({ value: categoryId, disabled: categoryId !== undefined }, - parameter_template: {}, + template: {}, default_value: {} }; }, [categoryId]); @@ -83,7 +83,7 @@ export default function PartCategoryTemplateTable({ accessor: 'category_detail.pathstring' }, { - accessor: 'parameter_template_detail.name', + accessor: 'template_detail.name', title: t`Parameter Template`, sortable: true, switchable: false @@ -99,8 +99,8 @@ export default function PartCategoryTemplateTable({ let units = ''; - if (record?.parameter_template_detail?.units) { - units = `[${record.parameter_template_detail.units}]`; + if (record?.template_detail?.units) { + units = `[${record.template_detail.units}]`; } return ( @@ -162,7 +162,9 @@ export default function PartCategoryTemplateTable({ tableActions: tableActions, enableDownload: true, params: { - category: categoryId + category: categoryId, + template_detail: true, + category_detail: true } }} />