Skip to content

Commit

Permalink
Exclude some common fields from django-import-export (#5349) (#5351)
Browse files Browse the repository at this point in the history
- Add "get_fields()" method to InvenTreeResource
- Override default behaviour and exclude some common fields
- Will flow down to any inheriting classes

(cherry picked from commit 9414512)

Co-authored-by: Oliver <oliver.henry.walters@gmail.com>
  • Loading branch information
github-actions[bot] and SchrodingersGat committed Jul 26, 2023
1 parent 46da332 commit afa7ed8
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions InvenTree/InvenTree/admin.py
Expand Up @@ -31,3 +31,15 @@ def export_resource(self, obj):
row[idx] = val

return row

def get_fields(self, **kwargs):
"""Return fields, with some common exclusions"""

fields = super().get_fields(**kwargs)

fields_to_exclude = [
'metadata',
'lft', 'rght', 'tree_id', 'level',
]

return [f for f in fields if f.column_name not in fields_to_exclude]

0 comments on commit afa7ed8

Please sign in to comment.