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

API search field bug (#10108)

* Additional unit tests

* Fix search field

* Additional unit test to apply search term

* Bump API version
This commit is contained in:
Oliver
2025-08-01 11:16:15 +10:00
committed by GitHub
parent b9a8ace614
commit 44bcf2c7e8
3 changed files with 50 additions and 2 deletions

View File

@@ -1,11 +1,15 @@
"""InvenTree API version information.""" """InvenTree API version information."""
# InvenTree API version # InvenTree API version
INVENTREE_API_VERSION = 375 INVENTREE_API_VERSION = 376
"""Increment this API version number whenever there is a significant change to the API that any clients need to know about.""" """Increment this API version number whenever there is a significant change to the API that any clients need to know about."""
INVENTREE_API_TEXT = """ INVENTREE_API_TEXT = """
v376 -> 2025-08-01 : https://github.com/inventree/InvenTree/pull/10108
- Fix search fields for ReturnOrderLineItem API list endpoint
v375 -> 2025-07-28 : https://github.com/inventree/InvenTree/pull/10095 v375 -> 2025-07-28 : https://github.com/inventree/InvenTree/pull/10095
- Sorts searched fields to keep API stable - Sorts searched fields to keep API stable

View File

@@ -1641,7 +1641,7 @@ class ReturnOrderLineItemList(
ordering_fields = ['reference', 'target_date', 'received_date'] ordering_fields = ['reference', 'target_date', 'received_date']
search_fields = [ search_fields = [
'item_serial', 'item__serial',
'item__part__name', 'item__part__name',
'item__part__description', 'item__part__description',
'reference', 'reference',

View File

@@ -2507,6 +2507,50 @@ class ReturnOrderTests(InvenTreeAPITestCase):
calendar = Calendar.from_ical(response.content) calendar = Calendar.from_ical(response.content)
self.assertIsInstance(calendar, Calendar) self.assertIsInstance(calendar, Calendar)
def test_export(self):
"""Test data export for the ReturnOrder API endpoints."""
# Export return orders
data = self.export_data(
reverse('api-return-order-list'),
export_format='csv',
decode=True,
expected_code=200,
)
self.process_csv(
data,
required_cols=['Reference', 'Customer'],
required_rows=models.ReturnOrder.objects.count(),
)
N = models.ReturnOrderLineItem.objects.count()
self.assertGreater(N, 0, 'No ReturnOrderLineItems found!')
# Export return order lines
data = self.export_data(
reverse('api-return-order-line-list'),
export_format='csv',
decode=True,
expected_code=200,
)
self.process_csv(
data, required_rows=N, required_cols=['Order', 'Reference', 'Target Date']
)
# Export again, with a search term
data = self.export_data(
reverse('api-return-order-line-list'),
params={'search': 'xyz'},
export_format='csv',
decode=True,
expected_code=200,
)
self.process_csv(
data, required_rows=0, required_cols=['Order', 'Reference', 'Target Date']
)
class OrderMetadataAPITest(InvenTreeAPITestCase): class OrderMetadataAPITest(InvenTreeAPITestCase):
"""Unit tests for the various metadata endpoints of API.""" """Unit tests for the various metadata endpoints of API."""