2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-06-19 05:25:42 +00:00

Add API endpoint and serializer for BuildItem model

This commit is contained in:
Oliver Walters
2019-04-29 22:59:42 +10:00
parent 17d9d25fb9
commit c29827e45a
5 changed files with 49 additions and 7 deletions

View File

@ -307,6 +307,12 @@ class Part(models.Model):
def used_in_count(self):
return self.used_in.count()
def required_parts(self):
parts = []
for bom in self.bom_items.all():
parts.append(bom.sub_part)
return parts
@property
def supplier_count(self):
# Return the number of supplier parts available for this part