diff --git a/InvenTree/order/models.py b/InvenTree/order/models.py index e88572ae55..4ab0d6621c 100644 --- a/InvenTree/order/models.py +++ b/InvenTree/order/models.py @@ -700,6 +700,30 @@ class SalesOrder(Order): def pending_line_count(self): return self.pending_line_items().count() + def completed_shipments(self): + """ + Return a queryset of the completed shipments for this order + """ + return self.shipments.exclude(shipment_date=None) + + def pending_shipments(self): + """ + Return a queryset of the pending shipments for this order + """ + + return self.shipments.filter(shipment_date=None) + + @property + def shipment_count(self): + return self.shipments.count() + + @property + def completed_shipment_count(self): + return self.completed_shipments().count() + + @property + def pending_shipment_count(self): + return self.pending_shipments().count() class PurchaseOrderAttachment(InvenTreeAttachment): """ diff --git a/InvenTree/order/templates/order/sales_order_base.html b/InvenTree/order/templates/order/sales_order_base.html index 80ff5bbd97..4a8457d074 100644 --- a/InvenTree/order/templates/order/sales_order_base.html +++ b/InvenTree/order/templates/order/sales_order_base.html @@ -135,6 +135,16 @@ src="{% static 'img/blank_image.png' %}" {% endif %} + + + {% trans "Completed Shipments" %} + + {{ order.completed_shipment_count }} / {{ order.shipment_count }} + {% if order.pending_shipment_count > 0 %} + {% trans "Incomplete" %} + {% endif %} + + {% if order.link %}