From de6f2d37e59e10d41f57cc3884de53c31a19c545 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Sat, 11 Apr 2020 23:05:07 +1000 Subject: [PATCH] Coalesce baby, yeah! --- InvenTree/part/api.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/InvenTree/part/api.py b/InvenTree/part/api.py index c44d23a79f..c9e38ea74b 100644 --- a/InvenTree/part/api.py +++ b/InvenTree/part/api.py @@ -225,8 +225,8 @@ class PartList(generics.ListCreateAPIView): ).annotate( # Quantity of items which are "in stock" in_stock=Coalesce(Sum('stock_items__quantity', filter=stock_filter), Decimal(0)), - on_order=Sum('supplier_parts__purchase_order_line_items__quantity', filter=order_filter), - building=Sum('builds__quantity', filter=build_filter), + on_order=Coalesce(Sum('supplier_parts__purchase_order_line_items__quantity', filter=order_filter), Decimal(0)), + building=Coalesce(Sum('builds__quantity', filter=build_filter), Decimal(0)), ) # If we are filtering by 'has_stock' status