2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-12-16 17:28:11 +00:00

Fix for Category Parameters

This commit is contained in:
Oliver Walters
2025-11-26 00:27:14 +00:00
parent b39c42dfba
commit 2478b08a60
3 changed files with 23 additions and 14 deletions

View File

@@ -318,7 +318,7 @@ class CategoryTree(ListAPI):
return queryset return queryset
class CategoryParameterList(DataExportViewMixin, ListCreateAPI): class CategoryParameterList(DataExportViewMixin, OutputOptionsMixin, ListCreateAPI):
"""API endpoint for accessing a list of PartCategoryParameterTemplate objects. """API endpoint for accessing a list of PartCategoryParameterTemplate objects.
- GET: Return a list of PartCategoryParameterTemplate objects - GET: Return a list of PartCategoryParameterTemplate objects

View File

@@ -1745,7 +1745,9 @@ class BomItemSerializer(
@register_importer() @register_importer()
class CategoryParameterTemplateSerializer( class CategoryParameterTemplateSerializer(
DataImportExportSerializerMixin, InvenTree.serializers.InvenTreeModelSerializer InvenTree.serializers.FilterableSerializerMixin,
DataImportExportSerializerMixin,
InvenTree.serializers.InvenTreeModelSerializer,
): ):
"""Serializer for the PartCategoryParameterTemplate model.""" """Serializer for the PartCategoryParameterTemplate model."""
@@ -1758,17 +1760,22 @@ class CategoryParameterTemplateSerializer(
'category', 'category',
'category_detail', 'category_detail',
'template', 'template',
# 'parameter_template_detail', 'template_detail',
'default_value', 'default_value',
] ]
# TODO: Re-implement this, but point to the ParameterTemplate model template_detail = enable_filter(
# parameter_template_detail = PartParameterTemplateSerializer( common.serializers.ParameterTemplateSerializer(
# source='parameter_template', many=False, read_only=True source='template', many=False, read_only=True
# ) ),
True,
)
category_detail = CategorySerializer( category_detail = enable_filter(
source='category', many=False, read_only=True, allow_null=True CategorySerializer(
source='category', many=False, read_only=True, allow_null=True
),
True,
) )

View File

@@ -37,7 +37,7 @@ export default function PartCategoryTemplateTable({
value: categoryId, value: categoryId,
disabled: categoryId !== undefined disabled: categoryId !== undefined
}, },
parameter_template: {}, template: {},
default_value: {} default_value: {}
}; };
}, [categoryId]); }, [categoryId]);
@@ -83,7 +83,7 @@ export default function PartCategoryTemplateTable({
accessor: 'category_detail.pathstring' accessor: 'category_detail.pathstring'
}, },
{ {
accessor: 'parameter_template_detail.name', accessor: 'template_detail.name',
title: t`Parameter Template`, title: t`Parameter Template`,
sortable: true, sortable: true,
switchable: false switchable: false
@@ -99,8 +99,8 @@ export default function PartCategoryTemplateTable({
let units = ''; let units = '';
if (record?.parameter_template_detail?.units) { if (record?.template_detail?.units) {
units = `[${record.parameter_template_detail.units}]`; units = `[${record.template_detail.units}]`;
} }
return ( return (
@@ -162,7 +162,9 @@ export default function PartCategoryTemplateTable({
tableActions: tableActions, tableActions: tableActions,
enableDownload: true, enableDownload: true,
params: { params: {
category: categoryId category: categoryId,
template_detail: true,
category_detail: true
} }
}} }}
/> />