diff --git a/InvenTree/part/models.py b/InvenTree/part/models.py index 6749fa0ad6..c2c1ba03c2 100644 --- a/InvenTree/part/models.py +++ b/InvenTree/part/models.py @@ -33,7 +33,7 @@ from InvenTree import helpers from InvenTree import validators from InvenTree.models import InvenTreeTree -from InvenTree.status_codes import BuildStatus, StockStatus +from InvenTree.status_codes import BuildStatus, StockStatus, OrderStatus from company.models import SupplierPart @@ -806,6 +806,16 @@ class Part(models.Model): return orders + def open_purchase_orders(self): + """ Return a list of open purchase orders against this part """ + + return [order for order in self.purchase_orders() if order.status in OrderStatus.OPEN] + + def closed_purchase_orders(self): + """ Return a list of closed purchase orders against this part """ + + return [order for order in self.purchase_orders() if order.status not in OrderStatus.OPEN] + def on_order(self): """ Return the total number of items on order for this part. """ diff --git a/InvenTree/part/templates/part/orders.html b/InvenTree/part/templates/part/orders.html index ed8beb9b42..8c9f0c3cee 100644 --- a/InvenTree/part/templates/part/orders.html +++ b/InvenTree/part/templates/part/orders.html @@ -7,12 +7,17 @@
-

Part Orders

+

Open Part Orders

-{% include "order/po_table.html" with orders=part.purchase_orders %} +{% include "order/po_table.html" with orders=part.open_purchase_orders %} + +{% if part.closed_purchase_orders|length > 0 %} +

Closed Orders

+{% include "order/po_table.html" with orders=part.closed_purchase_orders %} +{% endif %} {% endblock %} \ No newline at end of file