mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Small tweaks for BOM export
- Steps towards preventing circular BOMs - Improve formatting of exported BOM
This commit is contained in:
parent
d04fb0d826
commit
28e9d842bf
@ -131,11 +131,13 @@ class BomItemResource(ModelResource):
|
||||
|
||||
level = Field(attribute='level', readonly=True)
|
||||
|
||||
part = Field(attribute='part', widget=widgets.ForeignKeyWidget(Part))
|
||||
bom_id = Field(attribute='pk')
|
||||
|
||||
parent_part_id = Field(attribute='part', widget=widgets.ForeignKeyWidget(Part))
|
||||
|
||||
parent_part_name = Field(attribute='part__full_name', readonly=True)
|
||||
|
||||
id = Field(attribute='sub_part', widget=widgets.ForeignKeyWidget(Part))
|
||||
sub_part_id = Field(attribute='sub_part', widget=widgets.ForeignKeyWidget(Part))
|
||||
|
||||
sub_part_name = Field(attribute='sub_part__full_name', readonly=True)
|
||||
|
||||
@ -147,7 +149,12 @@ class BomItemResource(ModelResource):
|
||||
report_skipped = False
|
||||
clean_model_instances = True
|
||||
|
||||
exclude = ['checksum', ]
|
||||
exclude = [
|
||||
'checksum',
|
||||
'id',
|
||||
'part',
|
||||
'sub_part',
|
||||
]
|
||||
|
||||
|
||||
class BomItemAdmin(ImportExportModelAdmin):
|
||||
|
@ -53,12 +53,18 @@ def ExportBom(part, fmt='csv', cascade=False):
|
||||
|
||||
bom_items = []
|
||||
|
||||
uids = []
|
||||
|
||||
def add_items(items, level):
|
||||
# Add items at a given layer
|
||||
for item in items:
|
||||
|
||||
item.level = '-' * level
|
||||
|
||||
# Avoid circular BOM references
|
||||
if item.pk in uids:
|
||||
continue
|
||||
|
||||
bom_items.append(item)
|
||||
|
||||
if item.sub_part.assembly:
|
||||
|
Loading…
Reference in New Issue
Block a user