Merge pull request #1197 from SchrodingersGat/bom-fix

Fix variable scope issue
This commit is contained in:
Oliver 2021-01-03 10:30:47 +11:00 committed by GitHub
commit 11c6248b06
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 4 deletions

View File

@ -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):

View File

@ -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:

View File

@ -32,7 +32,7 @@
<div class="btn-group" role="group" aria-label="...">
{% if editing_enabled %}
<button class='btn btn-default' type='button' title='{% trans "Remove selected BOM items" %}' id='bom-item-delete'>
<span class='fas fa-trash-alt'></span>
<span class='fas fa-trash-alt icon-red'></span>
</button>
<button class='btn btn-primary' type='button' title='{% trans "Import BOM data" %}' id='bom-upload'>
<span class='fas fa-file-upload'></span> {% trans "Import from File" %}