From 3954b33fb7b09880146688aa8bb71472f23758e5 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Mon, 10 Jun 2019 23:05:14 +1000 Subject: [PATCH] Use 'on_order' count in calculation for parts we need to order --- InvenTree/order/admin.py | 1 + InvenTree/part/models.py | 3 ++- InvenTree/templates/required_part_table.html | 6 ++++-- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/InvenTree/order/admin.py b/InvenTree/order/admin.py index e6b8db5735..bbd95cd42a 100644 --- a/InvenTree/order/admin.py +++ b/InvenTree/order/admin.py @@ -21,6 +21,7 @@ class PurchaseOrderLineItemAdmin(admin.ModelAdmin): list_display = ( 'order', + 'part', 'quantity', 'reference' ) diff --git a/InvenTree/part/models.py b/InvenTree/part/models.py index c2c1ba03c2..67a82a9504 100644 --- a/InvenTree/part/models.py +++ b/InvenTree/part/models.py @@ -427,7 +427,7 @@ class Part(models.Model): then we need to restock. """ - return (self.total_stock - self.allocation_count) < self.minimum_stock + return (self.total_stock + self.on_order - self.allocation_count) < self.minimum_stock @property def can_build(self): @@ -816,6 +816,7 @@ class Part(models.Model): return [order for order in self.purchase_orders() if order.status not in OrderStatus.OPEN] + @property def on_order(self): """ Return the total number of items on order for this part. """ diff --git a/InvenTree/templates/required_part_table.html b/InvenTree/templates/required_part_table.html index 5a8c7e5734..24eae0012f 100644 --- a/InvenTree/templates/required_part_table.html +++ b/InvenTree/templates/required_part_table.html @@ -2,16 +2,18 @@ Part Description + Required In Stock - Allocated + On Order Net Stock {% for part in parts %} {{ part.full_name }} {{ part.description }} - {{ part.total_stock }} {{ part.allocation_count }} + {{ part.total_stock }} + {{ part.on_order }} {{ part.available_stock }} {% endfor %}