diff --git a/InvenTree/part/forms.py b/InvenTree/part/forms.py index 68912edd98..1cbbec0b42 100644 --- a/InvenTree/part/forms.py +++ b/InvenTree/part/forms.py @@ -319,7 +319,9 @@ class EditBomItemForm(HelperForm): ] # Prevent editing of the part associated with this BomItem - widgets = {'part': forms.HiddenInput()} + widgets = { + 'part': forms.HiddenInput() + } class PartPriceForm(forms.Form): diff --git a/InvenTree/part/models.py b/InvenTree/part/models.py index cf0c92899a..b9d63979e7 100644 --- a/InvenTree/part/models.py +++ b/InvenTree/part/models.py @@ -1074,7 +1074,7 @@ class Part(MPTTModel): self.bom_items.all().delete() - def getRequiredParts(self, recursive=False, parts=set()): + def getRequiredParts(self, recursive=False, parts=None): """ Return a list of parts required to make this part (i.e. BOM items). @@ -1083,7 +1083,10 @@ class Part(MPTTModel): parts: Set of parts already found (to prevent recursion issues) """ - items = self.bom_items.all().prefetch_related('sub_part') + if parts is None: + parts = set() + + items = BomItem.objects.filter(part=self.pk) for bom_item in items: diff --git a/InvenTree/part/templates/part/bom.html b/InvenTree/part/templates/part/bom.html index 38d07cb00e..0b24582220 100644 --- a/InvenTree/part/templates/part/bom.html +++ b/InvenTree/part/templates/part/bom.html @@ -32,7 +32,7 @@