From 6d4e0f51c41e2e925121aaf1f6cbaca225bb7ea4 Mon Sep 17 00:00:00 2001 From: Bhumin Paladiya <139330832+bhumin18@users.noreply.github.com> Date: Sun, 18 Oct 2026 03:53:59 +0530 Subject: [PATCH] Enhance search and ordering fields across remaining REST API endpoints (#12737) * Enhance search and ordering fields across remaining API endpoints * Fix StockTrackingList search fields and bump API version to 537 * Format stock/api.py with ruff preview style * Restore StockList.create serial validation handling to match upstream master * Format files with ruff preview style and fix StockList try-except * Restore StockList to match upstream master and keep stock/api.py diff minimal --------- Co-authored-by: Matthias Mair --- src/backend/InvenTree/InvenTree/api_version.py | 6 ++++-- src/backend/InvenTree/importer/api.py | 4 ++++ src/backend/InvenTree/machine/api.py | 2 +- src/backend/InvenTree/report/api.py | 3 +++ src/backend/InvenTree/stock/api.py | 2 +- 5 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/backend/InvenTree/InvenTree/api_version.py b/src/backend/InvenTree/InvenTree/api_version.py index b5f424848c..7469e45007 100644 --- a/src/backend/InvenTree/InvenTree/api_version.py +++ b/src/backend/InvenTree/InvenTree/api_version.py @@ -1,12 +1,14 @@ """InvenTree API version information.""" # InvenTree API version -INVENTREE_API_VERSION = 559 - +INVENTREE_API_VERSION = 560 """Increment this API version number whenever there is a significant change to the API that any clients need to know about.""" INVENTREE_API_TEXT = """ +v560 -> 2026-10-17 : https://github.com/inventree/InvenTree/pull/12737 + - Adds search and ordering fields across remaining API endpoints (machine, stock, importer, report) + v559 -> 2026-10-17 : https://github.com/inventree/InvenTree/pull/13023 - Enforce maximum length for "notes" field in stock-adjustment API endpoints diff --git a/src/backend/InvenTree/importer/api.py b/src/backend/InvenTree/importer/api.py index fd8c6024fd..763ed99a50 100644 --- a/src/backend/InvenTree/importer/api.py +++ b/src/backend/InvenTree/importer/api.py @@ -189,6 +189,10 @@ class DataImportColumnMappingList(DataImportSessionChildMixin, ListAPI): filterset_fields = ['session'] + ordering_fields = ['column_label', 'field_name', 'session'] + + search_fields = ['column_label', 'field_name'] + class DataImportColumnMappingDetail(DataImportSessionChildMixin, RetrieveUpdateAPI): """Detail endpoint for a single DataImportColumnMap object.""" diff --git a/src/backend/InvenTree/machine/api.py b/src/backend/InvenTree/machine/api.py index 48c8d6bf6d..e03fe6a58a 100644 --- a/src/backend/InvenTree/machine/api.py +++ b/src/backend/InvenTree/machine/api.py @@ -41,7 +41,7 @@ class MachineList(ListCreateAPI): ordering = ['-active', 'machine_type'] - search_fields = ['name'] + search_fields = ['name', 'machine_type', 'driver'] class MachineDetail(RetrieveUpdateDestroyAPI): diff --git a/src/backend/InvenTree/report/api.py b/src/backend/InvenTree/report/api.py index deb5acc5e0..2f83cc5272 100644 --- a/src/backend/InvenTree/report/api.py +++ b/src/backend/InvenTree/report/api.py @@ -373,6 +373,9 @@ class ReportAssetList(TemplatePermissionMixin, ListCreateAPI): queryset = report.models.ReportAsset.objects.all() serializer_class = report.serializers.ReportAssetSerializer + filter_backends = SEARCH_ORDER_FILTER + search_fields = ['description'] + ordering_fields = ['description'] class ReportAssetDetail(TemplatePermissionMixin, RetrieveUpdateDestroyAPI): diff --git a/src/backend/InvenTree/stock/api.py b/src/backend/InvenTree/stock/api.py index 62fb20630c..7625190774 100644 --- a/src/backend/InvenTree/stock/api.py +++ b/src/backend/InvenTree/stock/api.py @@ -559,7 +559,7 @@ class StockLocationTypeList(ListCreateAPI): ordering = ['-location_count'] - search_fields = ['name'] + search_fields = ['name', 'description'] def get_queryset(self): """Override the queryset method to include location count."""