mirror of
https://github.com/inventree/InvenTree.git
synced 2025-05-01 04:56: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:
parent
560f57333c
commit
c1b551d2e0
@ -780,7 +780,7 @@ class PurchaseOrder(TotalPriceMixin, Order):
|
|||||||
@property
|
@property
|
||||||
def is_complete(self):
|
def is_complete(self):
|
||||||
"""Return True if all line items have been received."""
|
"""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
|
@transaction.atomic
|
||||||
def receive_line_item(
|
def receive_line_item(
|
||||||
@ -1076,9 +1076,7 @@ class SalesOrder(TotalPriceMixin, Order):
|
|||||||
|
|
||||||
def is_completed(self):
|
def is_completed(self):
|
||||||
"""Check if this order is "shipped" (all line items delivered)."""
|
"""Check if this order is "shipped" (all line items delivered)."""
|
||||||
return self.lines.count() > 0 and all(
|
return all(line.is_completed() for line in self.lines.all())
|
||||||
line.is_completed() for line in self.lines.all()
|
|
||||||
)
|
|
||||||
|
|
||||||
def can_complete(self, raise_error=False, allow_incomplete_lines=False):
|
def can_complete(self, raise_error=False, allow_incomplete_lines=False):
|
||||||
"""Test if this SalesOrder can be completed.
|
"""Test if this SalesOrder can be completed.
|
||||||
|
@ -522,6 +522,11 @@ class PurchaseOrderTest(OrderTest):
|
|||||||
|
|
||||||
self.assignRole('purchase_order.add')
|
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
|
# Should fail due to incomplete lines
|
||||||
response = self.post(url, {}, expected_code=400)
|
response = self.post(url, {}, expected_code=400)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user