From 4b21f9faa6a5ff82f482f6d74607c5f0d3d81abb Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Thu, 2 Jul 2026 22:53:19 +0000 Subject: [PATCH] Adjust API filters --- src/backend/InvenTree/build/api.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/backend/InvenTree/build/api.py b/src/backend/InvenTree/build/api.py index a0edd054a1..a50d062720 100644 --- a/src/backend/InvenTree/build/api.py +++ b/src/backend/InvenTree/build/api.py @@ -457,8 +457,21 @@ class BuildLineFilter(FilterSet): # Fields on related models consumable = rest_filters.BooleanFilter( - label=_('Consumable'), field_name='bom_item__consumable' + label=_('Consumable'), method='filter_consumable' ) + + def filter_consumable(self, queryset, name, value): + """Filter the queryset based on the "effective" consumable status of the BOM item. + + A BuildLine is considered "consumable" if either the BOM item itself, + or the underlying part, is marked as consumable. + """ + return queryset.filter( + part_models.BomItem.consumable_filter( + consumable=str2bool(value), prefix='bom_item__' + ) + ) + optional = rest_filters.BooleanFilter( label=_('Optional'), field_name='bom_item__optional' )