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:
@ -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=[
|
||||
|
Reference in New Issue
Block a user