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:
mredpath2 2024-07-26 10:27:53 +10:00 committed by GitHub
parent 49a0f871d6
commit 86fb9f0a8c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 12 additions and 0 deletions

View File

@ -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
)

View File

@ -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

View File

@ -111,6 +111,7 @@ class BomExportTest(InvenTreeTestCase):
'Parent Name',
'Part ID',
'Part IPN',
'Part Revision',
'Part Name',
'Description',
'Assembly',