2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-07-11 07:24:15 +00:00

Allow searching of BOM List API endpoint (#3296)

* Allow searching of BOM List API endpoint

* Bump API version

* Adds ordering field options to BOM List API endpoint

* Add some unit testing for new API features

* Fixes for unit tests
This commit is contained in:
Oliver
2022-07-06 10:09:58 +10:00
committed by GitHub
parent 1235d47eca
commit 0787264930
4 changed files with 124 additions and 1 deletions

View File

@ -24,6 +24,7 @@ from common.models import InvenTreeSetting
from company.models import Company, ManufacturerPart, SupplierPart
from InvenTree.api import (APIDownloadMixin, AttachmentMixin,
ListCreateDestroyAPIView)
from InvenTree.filters import InvenTreeOrderingFilter
from InvenTree.helpers import DownloadFile, increment, isNull, str2bool
from InvenTree.mixins import (CreateAPI, ListAPI, ListCreateAPI, RetrieveAPI,
RetrieveUpdateAPI, RetrieveUpdateDestroyAPI,
@ -1756,12 +1757,32 @@ class BomList(ListCreateDestroyAPIView):
filter_backends = [
DjangoFilterBackend,
filters.SearchFilter,
filters.OrderingFilter,
InvenTreeOrderingFilter,
]
filterset_fields = [
]
search_fields = [
'reference',
'sub_part__name',
'sub_part__description',
'sub_part__IPN',
'sub_part__revision',
'sub_part__keywords',
'sub_part__category__name',
]
ordering_fields = [
'quantity',
'sub_part',
'available_stock',
]
ordering_field_aliases = {
'sub_part': 'sub_part__name',
}
class BomImportUpload(CreateAPI):
"""API endpoint for uploading a complete Bill of Materials.