2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-04-30 12:36:45 +00:00

Allow orders to be completed without any "lines" (#8258)

* Allow orders to be completed without any "lines"

Note: There may be "extra lines" for these orders!

* Fix for unit test
This commit is contained in:
Oliver 2024-10-09 15:46:41 +11:00 committed by GitHub
parent 560f57333c
commit c1b551d2e0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 7 additions and 4 deletions

View File

@ -780,7 +780,7 @@ class PurchaseOrder(TotalPriceMixin, Order):
@property
def is_complete(self):
"""Return True if all line items have been received."""
return self.lines.count() > 0 and self.pending_line_items().count() == 0
return self.pending_line_items().count() == 0
@transaction.atomic
def receive_line_item(
@ -1076,9 +1076,7 @@ class SalesOrder(TotalPriceMixin, Order):
def is_completed(self):
"""Check if this order is "shipped" (all line items delivered)."""
return self.lines.count() > 0 and all(
line.is_completed() for line in self.lines.all()
)
return all(line.is_completed() for line in self.lines.all())
def can_complete(self, raise_error=False, allow_incomplete_lines=False):
"""Test if this SalesOrder can be completed.

View File

@ -522,6 +522,11 @@ class PurchaseOrderTest(OrderTest):
self.assignRole('purchase_order.add')
# Add a line item
sp = SupplierPart.objects.filter(supplier=po.supplier).first()
models.PurchaseOrderLineItem.objects.create(part=sp, order=po, quantity=100)
# Should fail due to incomplete lines
response = self.post(url, {}, expected_code=400)