mirror of
https://github.com/inventree/InvenTree.git
synced 2025-06-21 06:16:29 +00:00
Lots of work towards multiple build output
This commit is contained in:
@ -905,6 +905,18 @@ class Part(MPTTModel):
|
||||
def has_bom(self):
|
||||
return self.bom_count > 0
|
||||
|
||||
def has_trackable_parts(self):
|
||||
"""
|
||||
Return True if any parts linked in the Bill of Materials are trackable.
|
||||
This is important when building the part.
|
||||
"""
|
||||
|
||||
for bom_item in self.bom_items.all():
|
||||
if bom_item.sub_part.trackable:
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
@property
|
||||
def bom_count(self):
|
||||
""" Return the number of items contained in the BOM for this part """
|
||||
@ -1188,7 +1200,7 @@ class Part(MPTTModel):
|
||||
parameter.save()
|
||||
|
||||
@transaction.atomic
|
||||
def deepCopy(self, other, **kwargs):
|
||||
def deep_copy(self, other, **kwargs):
|
||||
""" Duplicates non-field data from another part.
|
||||
Does not alter the normal fields of this part,
|
||||
but can be used to copy other data linked by ForeignKey refernce.
|
||||
|
@ -99,7 +99,7 @@ class PartTest(TestCase):
|
||||
self.assertIn(self.R1.name, barcode)
|
||||
|
||||
def test_copy(self):
|
||||
self.R2.deepCopy(self.R1, image=True, bom=True)
|
||||
self.R2.deep_copy(self.R1, image=True, bom=True)
|
||||
|
||||
def test_match_names(self):
|
||||
|
||||
|
@ -360,7 +360,7 @@ class MakePartVariant(AjaxCreateView):
|
||||
parameters_copy = str2bool(request.POST.get('parameters_copy', False))
|
||||
|
||||
# Copy relevent information from the template part
|
||||
part.deepCopy(part_template, bom=bom_copy, parameters=parameters_copy)
|
||||
part.deep_copy(part_template, bom=bom_copy, parameters=parameters_copy)
|
||||
|
||||
return self.renderJsonResponse(request, form, data, context=context)
|
||||
|
||||
@ -473,7 +473,7 @@ class PartDuplicate(AjaxCreateView):
|
||||
original = self.get_part_to_copy()
|
||||
|
||||
if original:
|
||||
part.deepCopy(original, bom=bom_copy, parameters=parameters_copy)
|
||||
part.deep_copy(original, bom=bom_copy, parameters=parameters_copy)
|
||||
|
||||
try:
|
||||
data['url'] = part.get_absolute_url()
|
||||
|
Reference in New Issue
Block a user