From d1338e210e757cec1b72025fcae98439eb7f65c3 Mon Sep 17 00:00:00 2001 From: Oliver Date: Wed, 16 Mar 2022 23:01:46 +1100 Subject: [PATCH] Only display "outstanding" sales order allocations in table --- InvenTree/order/api.py | 8 +++++++- InvenTree/templates/js/translated/stock.js | 4 ++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/InvenTree/order/api.py b/InvenTree/order/api.py index 2d079f8d45..fb175d3037 100644 --- a/InvenTree/order/api.py +++ b/InvenTree/order/api.py @@ -886,9 +886,15 @@ class SOAllocationList(generics.ListAPIView): outstanding = str2bool(outstanding) if outstanding: - queryset = queryset.filter(line__order__status__in=SalesOrderStatus.OPEN) + # Filter only "open" orders + # Filter only allocations which have *not* shipped + queryset = queryset.filter( + line__order__status__in=SalesOrderStatus.OPEN, + shipment__shipment_date=None, + ) else: queryset = queryset.exclude(line__order__status__in=SalesOrderStatus.OPEN) + queryset = queryset.exclude(shipment__shipment_date=None) return queryset diff --git a/InvenTree/templates/js/translated/stock.js b/InvenTree/templates/js/translated/stock.js index 421a784281..3cbf6d7634 100644 --- a/InvenTree/templates/js/translated/stock.js +++ b/InvenTree/templates/js/translated/stock.js @@ -2353,6 +2353,10 @@ function loadStockAllocationTable(table, options={}) { query_params.customer_detail = true; query_params.order_detail = true; + // Note: SalesOrderAllocations do not get deleted, + // so we must filter by "outstanding" status + query_params.outstanding = true; + delete query_params.build_detail; // Load sales order allocation data