2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-08-10 05:40:55 +00:00

Generate a list of allowed BOM items and pass to the form template

This commit is contained in:
Oliver Walters
2019-07-07 11:22:01 +10:00
parent 3930651c59
commit bd30ac037b
3 changed files with 24 additions and 0 deletions

View File

@@ -678,6 +678,18 @@ class Part(models.Model):
parts.append(bom.sub_part)
return parts
def get_allowed_bom_items(self):
""" Return a list of parts which can be added to a BOM for this part.
- Exclude parts which are not 'component' parts
- Exclude parts which this part is in the BOM for
"""
parts = Part.objects.filter(component=True)
parts = parts.exclude(id__in=[part.id for part in self.used_in.all()])
return parts
@property
def supplier_count(self):
""" Return the number of supplier parts available for this part """