mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Add substitute details to BOM export (#7563)
* Included substitute IPN to BOM export * Added Part Revision to BOM export * removed trailing whitespace * Update test_bom_export.py Added Part Revision to test --------- Co-authored-by: Matthias Mair <code@mjmair.com>
This commit is contained in:
parent
49a0f871d6
commit
86fb9f0a8c
@ -401,6 +401,9 @@ class BomItemResource(InvenTreeResource):
|
||||
part_ipn = Field(
|
||||
attribute='sub_part__IPN', column_name=_('Part IPN'), readonly=True
|
||||
)
|
||||
part_revision = Field(
|
||||
attribute='sub_part__revision', column_name=_('Part Revision'), readonly=True
|
||||
)
|
||||
part_name = Field(
|
||||
attribute='sub_part__name', column_name=_('Part Name'), readonly=True
|
||||
)
|
||||
|
@ -117,6 +117,14 @@ def ExportBom(
|
||||
for bom_item in bom_items:
|
||||
substitutes = BomItemSubstitute.objects.filter(bom_item=bom_item)
|
||||
for s_idx, substitute in enumerate(substitutes):
|
||||
"""Create substitute part IPN column"""
|
||||
name = f'{_("Substitute IPN")}{s_idx + 1}'
|
||||
value = substitute.part.IPN
|
||||
try:
|
||||
substitute_cols[name].update({col_index: value})
|
||||
except KeyError:
|
||||
substitute_cols[name] = {col_index: value}
|
||||
|
||||
"""Create substitute part name column"""
|
||||
name = f'{_("Substitute Part")}{s_idx + 1}'
|
||||
value = substitute.part.name
|
||||
|
@ -111,6 +111,7 @@ class BomExportTest(InvenTreeTestCase):
|
||||
'Parent Name',
|
||||
'Part ID',
|
||||
'Part IPN',
|
||||
'Part Revision',
|
||||
'Part Name',
|
||||
'Description',
|
||||
'Assembly',
|
||||
|
Loading…
Reference in New Issue
Block a user