From 9ba6ac423ded4bbb36b3ed45bd73dcb5b977e330 Mon Sep 17 00:00:00 2001 From: Oliver Date: Sat, 4 Dec 2021 10:16:51 +1100 Subject: [PATCH] Add shipment status to sales order page --- InvenTree/order/models.py | 24 +++++++++++++++++++ .../templates/order/sales_order_base.html | 10 ++++++++ 2 files changed, 34 insertions(+) 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 %}