diff --git a/InvenTree/company/models.py b/InvenTree/company/models.py index 33841d59db..069ecb0ad6 100644 --- a/InvenTree/company/models.py +++ b/InvenTree/company/models.py @@ -327,7 +327,7 @@ class SupplierPart(models.Model): if q is None or r is None: return 0 else: - return q - r + return max(q-r, 0) def purchase_orders(self): diff --git a/InvenTree/part/models.py b/InvenTree/part/models.py index f1294a972d..6749fa0ad6 100644 --- a/InvenTree/part/models.py +++ b/InvenTree/part/models.py @@ -809,7 +809,7 @@ class Part(models.Model): def on_order(self): """ Return the total number of items on order for this part. """ - return sum([part.on_order() for part in self.supplier_parts.all()]) + return sum([part.on_order() for part in self.supplier_parts.all().prefetch_related('purchase_order_line_items')]) def attach_file(instance, filename):