Separate display of open and closed purchase orders (per part)

This commit is contained in:
Oliver Walters 2019-06-10 22:31:19 +10:00
parent 228bf4e1da
commit b8bcc5ce0c
2 changed files with 18 additions and 3 deletions

View File

@ -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. """

View File

@ -7,12 +7,17 @@
<div class='row'>
<div class='col-sm-6'>
<h4>Part Orders</h4>
<h4>Open Part Orders</h4>
</div>
<div class='col-sm-6'>
</div>
</div>
{% 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 %}
<h4>Closed Orders</h4>
{% include "order/po_table.html" with orders=part.closed_purchase_orders %}
{% endif %}
{% endblock %}