2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-06-16 03:55:41 +00:00

Add new view to duplicate a part

- Allows 'deep_copy' (copies all BOM items for the duplicated part)
This commit is contained in:
Oliver Walters
2019-05-13 21:41:32 +10:00
parent 6ae185ec0e
commit 2408318eae
9 changed files with 174 additions and 22 deletions

View File

@ -533,6 +533,19 @@ class Part(models.Model):
""" Return the number of supplier parts available for this part """
return self.supplier_parts.count()
def copyBomFrom(self, other):
""" Duplicates the BOM from another part.
This should only be called during part creation,
and it does not delete any existing BOM items for *this* part.
"""
for item in other.bom_items.all():
# Point the item to THIS part
item.part = self
item.pk = None
item.save()
def export_bom(self, **kwargs):
data = tablib.Dataset(headers=[