mirror of
				https://github.com/inventree/InvenTree.git
				synced 2025-10-31 05:05:42 +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:
		| @@ -401,6 +401,9 @@ class BomItemResource(InvenTreeResource): | |||||||
|     part_ipn = Field( |     part_ipn = Field( | ||||||
|         attribute='sub_part__IPN', column_name=_('Part IPN'), readonly=True |         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( |     part_name = Field( | ||||||
|         attribute='sub_part__name', column_name=_('Part Name'), readonly=True |         attribute='sub_part__name', column_name=_('Part Name'), readonly=True | ||||||
|     ) |     ) | ||||||
|   | |||||||
| @@ -117,6 +117,14 @@ def ExportBom( | |||||||
|         for bom_item in bom_items: |         for bom_item in bom_items: | ||||||
|             substitutes = BomItemSubstitute.objects.filter(bom_item=bom_item) |             substitutes = BomItemSubstitute.objects.filter(bom_item=bom_item) | ||||||
|             for s_idx, substitute in enumerate(substitutes): |             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""" |                 """Create substitute part name column""" | ||||||
|                 name = f'{_("Substitute Part")}{s_idx + 1}' |                 name = f'{_("Substitute Part")}{s_idx + 1}' | ||||||
|                 value = substitute.part.name |                 value = substitute.part.name | ||||||
|   | |||||||
| @@ -111,6 +111,7 @@ class BomExportTest(InvenTreeTestCase): | |||||||
|                 'Parent Name', |                 'Parent Name', | ||||||
|                 'Part ID', |                 'Part ID', | ||||||
|                 'Part IPN', |                 'Part IPN', | ||||||
|  |                 'Part Revision', | ||||||
|                 'Part Name', |                 'Part Name', | ||||||
|                 'Description', |                 'Description', | ||||||
|                 'Assembly', |                 'Assembly', | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user