Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 14 additions & 8 deletions test/test_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ def test_po_create(self):
reference=ref,
description="This is a PO created using the Python interface"
)
assert po

self.assertIsNotNone(po)
self.assertIsNotNone(po.pk)
Expand Down Expand Up @@ -119,6 +120,7 @@ def test_po_create(self):
continue

line = po.addLineItem(part=sp.pk, quantity=idx)
assert line

self.assertEqual(line.getOrder().pk, po.pk)

Expand Down Expand Up @@ -147,7 +149,7 @@ def test_po_create(self):

# Let's add some!
extraline = po.addExtraLineItem(quantity=1, reference="Transport costs", notes="Extra line item added from Python interface", price=10, price_currency="EUR")

assert extraline
self.assertEqual(extraline.getOrder().pk, po.pk)

self.assertIsNotNone(extraline)
Expand All @@ -173,6 +175,7 @@ def test_order_cancel(self):
'reference': ref,
'description': 'Some new order'
})
assert po

self.assertEqual(po.status, 10)
self.assertEqual(po.status_text, "Pending")
Expand All @@ -196,6 +199,7 @@ def test_order_complete_with_receive(self):
'reference': ref,
'description': 'A purchase order with items to be received',
})
assert po

# Get first location
use_location = stock.StockLocation.list(self.api, limit=1)[0]
Expand Down Expand Up @@ -267,6 +271,7 @@ def test_order_complete_with_receive(self):
# Receive all line items
# Use the ID of the location here
result = po.receiveAll(location=use_location.pk)
assert result

# Check the result returned
if self.api.api_version < 385: # Ref: https://github.com/inventree/InvenTree/pull/10174/
Expand All @@ -284,14 +289,8 @@ def test_order_complete_with_receive(self):
result = po.receiveAll(location=use_location)
self.assertIsNone(result)

# hold the order, then complete it
po._statusupdate(status='hold')

# Complete the order, do not accept any incomplete lines
po.complete(accept_incomplete=False)
po.reload()

# Check that the order is now complete
po.reload()
self.assertEqual(po.status, 30)

def test_order_complete(self):
Expand All @@ -306,6 +305,7 @@ def test_order_complete(self):
'reference': ref,
'description': 'A new purchase order',
})
assert po

# Add some line items
for p in company.SupplierPart.list(self.api, supplier=1, limit=5):
Expand Down Expand Up @@ -377,6 +377,7 @@ def test_po_attachment(self):
'reference': f'PO-{n + 100}',
'description': 'A new purchase order',
})
assert po

attachments = po.getAttachments()
self.assertEqual(len(attachments), 0)
Expand Down Expand Up @@ -558,6 +559,7 @@ def test_so_attachment(self):
'customer': 4,
"description": "Selling some stuff",
})
assert so

n = len(so.getAttachments())

Expand All @@ -584,6 +586,7 @@ def test_so_shipment(self):
'customer': 4,
"description": "Selling some stuff",
})
assert so

# Add some line items to the SalesOrder
for p in part.Part.list(self.api, is_template=False, salable=True, limit=5):
Expand Down Expand Up @@ -645,6 +648,7 @@ def test_so_shipment(self):
shipment_2 = so.addShipment(f'Package {num_shipments + 1}')

# Assert the shipment is not created
assert shipment_2
self.assertIsNotNone(shipment_2)

# Assert the shipment Order is equal to the expected one
Expand All @@ -671,6 +675,7 @@ def test_so_shipment(self):
)

# Assert the shipment is created
assert shipment_2
self.assertIsNotNone(shipment_2)

# Assert the shipment Order is equal to the expected one
Expand Down Expand Up @@ -790,6 +795,7 @@ def test_ro_create(self):
reference=ref,
description="A new return order"
)
assert ro

self.assertIsNotNone(ro)
self.assertIsNotNone(ro.pk)
Expand Down
Loading