mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Customize admin export of Part object
This commit is contained in:
parent
03a42fa360
commit
8a68313e5e
@ -1,5 +1,7 @@
|
||||
from django.contrib import admin
|
||||
from import_export.admin import ImportExportModelAdmin
|
||||
from import_export.admin import ImportExportModelAdmin, ImportExportActionModelAdmin
|
||||
from import_export.resources import ModelResource
|
||||
from import_export.fields import Field
|
||||
|
||||
from .models import PartCategory, Part
|
||||
from .models import PartAttachment, PartStar
|
||||
@ -7,8 +9,35 @@ from .models import BomItem
|
||||
from .models import PartParameterTemplate, PartParameter
|
||||
|
||||
|
||||
class PartResource(ModelResource):
|
||||
""" Class for managing Part model export """
|
||||
|
||||
# Constuct some extra fields for export
|
||||
category = Field(attribute='category__pk', column_name='Category')
|
||||
|
||||
category_name = Field(attribute='category__name', column_name='Category Name')
|
||||
|
||||
default_location = Field(attribute='default_location__pk', column_name='Default Location')
|
||||
|
||||
default_supplier = Field(attribute='default_supplier__pk', column_name='Default Supplier')
|
||||
|
||||
in_stock = Field(attribute='total_stock')
|
||||
|
||||
on_order = Field(attribute='on_order')
|
||||
|
||||
variant_of = Field(attribute='variant_of__pk')
|
||||
|
||||
class Meta:
|
||||
model = Part
|
||||
exclude = [
|
||||
'bom_checksum', 'bom_checked_by', 'bom_checked_date'
|
||||
]
|
||||
|
||||
|
||||
class PartAdmin(ImportExportModelAdmin):
|
||||
|
||||
resource_class = PartResource
|
||||
|
||||
list_display = ('full_name', 'description', 'total_stock', 'category')
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user