Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add substitute details to BOM export #7563

Merged
merged 5 commits into from
Jul 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/backend/InvenTree/part/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,9 @@ class Meta:
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
)
Expand Down
8 changes: 8 additions & 0 deletions src/backend/InvenTree/part/bom.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,14 @@ def add_columns_to_dataset(columns, column_size):
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
Expand Down
1 change: 1 addition & 0 deletions src/backend/InvenTree/part/test_bom_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ def test_export_csv(self):
'Parent Name',
'Part ID',
'Part IPN',
'Part Revision',
'Part Name',
'Description',
'Assembly',
Expand Down
Loading