Prevent BOM price calculation from becoming too recursive

This commit is contained in:
Oliver Walters 2020-04-21 21:38:22 +10:00
parent cb636e000d
commit 4979c690d9

View File

@ -824,6 +824,11 @@ class Part(models.Model):
max_price = None max_price = None
for item in self.bom_items.all().select_related('sub_part'): 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) prices = item.sub_part.get_price_range(quantity * item.quantity)
if prices is None: if prices is None: