From 4979c690d9deefa43435f7efcfec23071ff96796 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Tue, 21 Apr 2020 21:38:22 +1000 Subject: [PATCH] Prevent BOM price calculation from becoming too recursive --- InvenTree/part/models.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/InvenTree/part/models.py b/InvenTree/part/models.py index 8405afd972..79445fd02d 100644 --- a/InvenTree/part/models.py +++ b/InvenTree/part/models.py @@ -824,6 +824,11 @@ class Part(models.Model): max_price = None for item in self.bom_items.all().select_related('sub_part'): + + if item.sub_part.pk == self.pk: + print("Warning: Item contains itself in BOM") + continue + prices = item.sub_part.get_price_range(quantity * item.quantity) if prices is None: