Bug fix for exporting SalesOrderAllocation data (#12463)

* Bug fix for exporting SalesOrderAllocation data

* Regression test

* Bump API version

* Bug fix for unit test
This commit is contained in:
Oliver
2026-07-24 15:38:14 +10:00
committed by GitHub
parent 6bd4842fd8
commit 7d8b3ff160
4 changed files with 37 additions and 2 deletions
@@ -1,11 +1,14 @@
"""InvenTree API version information."""
# InvenTree API version
INVENTREE_API_VERSION = 525
INVENTREE_API_VERSION = 526
"""Increment this API version number whenever there is a significant change to the API that any clients need to know about."""
INVENTREE_API_TEXT = """
v526 -> 2026-07-24 : https://github.com/inventree/InvenTree/pull/12463
- Fix for data export on SalesOrderAllocation API endpoint
v525 -> 2026-07-20 : https://github.com/inventree/InvenTree/pull/12409
- Type clarifications for some fields; no functional changes
+1
View File
@@ -1362,6 +1362,7 @@ class SalesOrderAllocationList(
SalesOrderAllocationMixin,
BulkDeleteMixin,
BulkUpdateMixin,
DataExportViewMixin,
OutputOptionsMixin,
ListAPI,
):
+2 -1
View File
@@ -26,6 +26,7 @@ from company.serializers import (
ContactSerializer,
SupplierPartSerializer,
)
from data_exporter.mixins import DataExportSerializerMixin
from generic.states.fields import InvenTreeCustomStatusSerializerMixin
from importer.registry import register_importer
from InvenTree.helpers import extract_serial_numbers, hash_barcode, normalize, str2bool
@@ -1543,7 +1544,7 @@ class SalesOrderShipmentSerializer(
class SalesOrderAllocationSerializer(
FilterableSerializerMixin, InvenTreeModelSerializer
DataExportSerializerMixin, FilterableSerializerMixin, InvenTreeModelSerializer
):
"""Serializer for the SalesOrderAllocation model.
+30
View File
@@ -2841,6 +2841,36 @@ class SalesOrderAllocateTest(OrderTest):
response = self.post(self.url, data, expected_code=201)
class SalesOrderAllocationDownloadTest(OrderTest):
"""Unit tests for downloading SalesOrderAllocation data via the API endpoint."""
def test_download_csv(self):
"""Test that SalesOrderAllocation data can be downloaded as a .csv file.
Regression test for a bug where the SalesOrderAllocation list endpoint
did not support data export.
"""
url = reverse('api-so-allocation-list')
required_cols = ['ID', 'Item', 'Quantity', 'Shipment', 'Line', 'Part', 'Order']
with self.export_data(url, export_format='csv', expected_code=200) as file:
data = self.process_csv(
file,
required_cols=required_cols,
required_rows=SalesOrderAllocation.objects.count(),
)
for row in data:
allocation = SalesOrderAllocation.objects.get(pk=row['ID'])
self.assertEqual(row['Item'], str(allocation.item.pk))
self.assertEqual(float(row['Quantity']), float(allocation.quantity))
self.assertEqual(row['Line'], str(allocation.line.pk))
self.assertEqual(row['Part'], str(allocation.item.part.pk))
self.assertEqual(row['Order'], str(allocation.line.order.pk))
class SalesOrderAllocateSerialsTest(OrderTest):
"""Unit tests for allocating stock items against a SalesOrder, by serial number."""