2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-09-14 06:31:27 +00:00

[UI] Build page tweak (#10027)

* Hide "consumed stock" panel if not required

* Docs updates

* Hide allocation fields if the build has no required parts

* Additional serializer options
This commit is contained in:
Oliver
2025-07-15 18:27:09 +10:00
committed by GitHub
parent 42abc61494
commit 75ab57bc0b
4 changed files with 62 additions and 22 deletions

View File

@@ -532,8 +532,10 @@ class BuildLineEndpoint:
try:
params = self.request.query_params
kwargs['bom_item_detail'] = str2bool(params.get('bom_item_detail', True))
kwargs['part_detail'] = str2bool(params.get('part_detail', True))
kwargs['build_detail'] = str2bool(params.get('build_detail', False))
kwargs['allocations'] = str2bool(params.get('allocations', True))
except AttributeError:
pass

View File

@@ -1328,19 +1328,27 @@ class BuildLineSerializer(DataImportExportSerializerMixin, InvenTreeModelSeriali
def __init__(self, *args, **kwargs):
"""Determine which extra details fields should be included."""
part_detail = kwargs.pop('part_detail', True)
bom_item_detail = kwargs.pop('bom_item_detail', True)
build_detail = kwargs.pop('build_detail', True)
allocations = kwargs.pop('allocations', True)
super().__init__(*args, **kwargs)
if isGeneratingSchema():
return
if not bom_item_detail:
self.fields.pop('bom_item_detail', None)
if not part_detail:
self.fields.pop('part_detail', None)
if not build_detail:
self.fields.pop('build_detail', None)
if not allocations:
self.fields.pop('allocations', None)
# Build info fields
build_reference = serializers.CharField(
source='build.reference', label=_('Build Reference'), read_only=True