2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-09-18 08:31:33 +00:00

Fix export of order data (#4714)

* Adds extra unit test for exporting sales orders

- Exporting sales orders to .xls currently throws exception

* Fix 'total_price' field when exporting orders

* Fix for unit test
This commit is contained in:
Oliver
2023-04-28 06:54:50 +10:00
committed by GitHub
parent f6021c4749
commit f6831558a4
3 changed files with 58 additions and 11 deletions

View File

@@ -1452,6 +1452,28 @@ class SalesOrderTest(OrderTest):
self.assertGreaterEqual(n_events, 1)
self.assertEqual(number_orders_incl_complete, n_events)
def test_export(self):
"""Test we can export the SalesOrder list"""
n = models.SalesOrder.objects.count()
# Check there are some sales orders
self.assertGreater(n, 0)
for order in models.SalesOrder.objects.all():
# Reconstruct the total price
order.save()
# Download file, check we get a 200 response
for fmt in ['csv', 'xls', 'xlsx']:
self.download_file(
reverse('api-so-list'),
{'export': fmt},
decode=True if fmt == 'csv' else False,
expected_code=200,
expected_fn=f"InvenTree_SalesOrders.{fmt}"
)
class SalesOrderLineItemTest(OrderTest):
"""Tests for the SalesOrderLineItem API."""