2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-07-02 03:30:54 +00:00

Add "optional" field to BomItem

- Defaults to False
- Indicates that the BomItem is "optional" for a build
- Will be used in the future when calculating if a Build output is fully allocated!
This commit is contained in:
Oliver Walters
2020-10-05 00:42:09 +11:00
parent c1595396c4
commit 3ee7be1d58
6 changed files with 41 additions and 4 deletions

View File

@ -765,20 +765,30 @@ class BomList(generics.ListCreateAPIView):
queryset = super().filter_queryset(queryset)
params = self.request.query_params
# Filter by "optional" status?
optional = params.get('optional', None)
if optional is not None:
optional = str2bool(optional)
queryset = queryset.filter(optional=optional)
# Filter by part?
part = self.request.query_params.get('part', None)
part = params.get('part', None)
if part is not None:
queryset = queryset.filter(part=part)
# Filter by sub-part?
sub_part = self.request.query_params.get('sub_part', None)
sub_part = params.get('sub_part', None)
if sub_part is not None:
queryset = queryset.filter(sub_part=sub_part)
# Filter by "trackable" status of the sub-part
trackable = self.request.query_params.get('trackable', None)
trackable = params.get('trackable', None)
if trackable is not None:
trackable = str2bool(trackable)