2
0
mirror of https://github.com/inventree/InvenTree.git synced 2026-04-06 19:41:16 +00:00

Display more output information in "build allocated stock" table (#11276)

* Add "install_into_detail" to BuildItem serializer

* Enhance the "resolveItem" function

* Add "StockColumn" renderer

* Fix output column for BuildAllocatedStockTable

* Replace column in stock item table

* More column refactoring

* Bump API version

* Add InvenTreeOutputOption descriptions

* Prefetch for better API performance

* Updated playwright testing
This commit is contained in:
Oliver
2026-02-11 23:25:56 +11:00
committed by GitHub
parent e963b8219b
commit 3ebf27df36
11 changed files with 282 additions and 235 deletions

View File

@@ -1,11 +1,14 @@
"""InvenTree API version information."""
# InvenTree API version
INVENTREE_API_VERSION = 451
INVENTREE_API_VERSION = 452
"""Increment this API version number whenever there is a significant change to the API that any clients need to know about."""
INVENTREE_API_TEXT = """
v452 -> 2026-02-10 : https://github.com/inventree/InvenTree/pull/11276
- Adds "install_into_detail" field to the BuildItem API endpoint
v451 -> 2026-02-10 : https://github.com/inventree/InvenTree/pull/11277
- Adds sorting to multiple part related endpoints (part, IPN, ...)

View File

@@ -808,13 +808,17 @@ class BuildCancel(BuildOrderContextMixin, CreateAPI):
serializer_class = build.serializers.BuildCancelSerializer
class BuildItemDetail(RetrieveUpdateDestroyAPI):
"""API endpoint for detail view of a BuildItem object."""
class BuildItemMixin:
"""Mixin class for BuildItem API endpoints."""
queryset = BuildItem.objects.all()
queryset = BuildItem.objects.all().prefetch_related('stock_item__location')
serializer_class = build.serializers.BuildItemSerializer
class BuildItemDetail(BuildItemMixin, RetrieveUpdateDestroyAPI):
"""API endpoint for detail view of a BuildItem object."""
class BuildItemFilter(FilterSet):
"""Custom filterset for the BuildItemList API endpoint."""
@@ -899,16 +903,45 @@ class BuildItemOutputOptions(OutputConfiguration):
"""Output options for BuildItem endpoint."""
OPTIONS = [
InvenTreeOutputOption('part_detail'),
InvenTreeOutputOption('location_detail'),
InvenTreeOutputOption('stock_detail'),
InvenTreeOutputOption('build_detail'),
InvenTreeOutputOption('supplier_part_detail'),
InvenTreeOutputOption(
'part_detail',
default=False,
description='Include detailed information about the part associated with this build item.',
),
InvenTreeOutputOption(
'location_detail',
default=False,
description='Include detailed information about the location of the allocated stock item.',
),
InvenTreeOutputOption(
'stock_detail',
default=False,
description='Include detailed information about the allocated stock item.',
),
InvenTreeOutputOption(
'build_detail',
default=False,
description='Include detailed information about the associated build order.',
),
InvenTreeOutputOption(
'supplier_part_detail',
default=False,
description='Include detailed information about the supplier part associated with this build item.',
),
InvenTreeOutputOption(
'install_into_detail',
default=False,
description='Include detailed information about the build output for this build item.',
),
]
class BuildItemList(
DataExportViewMixin, OutputOptionsMixin, BulkDeleteMixin, ListCreateAPI
BuildItemMixin,
DataExportViewMixin,
OutputOptionsMixin,
BulkDeleteMixin,
ListCreateAPI,
):
"""API endpoint for accessing a list of BuildItem objects.
@@ -917,8 +950,6 @@ class BuildItemList(
"""
output_options = BuildItemOutputOptions
queryset = BuildItem.objects.all()
serializer_class = build.serializers.BuildItemSerializer
filterset_class = BuildItemFilter
filter_backends = SEARCH_ORDER_FILTER_ALIAS

View File

@@ -1179,6 +1179,7 @@ class BuildItemSerializer(
'part_detail',
'stock_item_detail',
'supplier_part_detail',
'install_into_detail',
# The following fields are only used for data export
'bom_reference',
'bom_part_id',
@@ -1244,6 +1245,21 @@ class BuildItemSerializer(
],
)
install_into_detail = enable_filter(
StockItemSerializer(
source='install_into',
read_only=True,
allow_null=True,
label=_('Install Into'),
part_detail=False,
location_detail=False,
supplier_part_detail=False,
path_detail=False,
),
False,
prefetch_fields=['install_into', 'install_into__part'],
)
location = serializers.PrimaryKeyRelatedField(
label=_('Location'), source='stock_item.location', many=False, read_only=True
)