mirror of
https://github.com/inventree/InvenTree.git
synced 2025-04-29 12:06:44 +00:00
Add autocomplete admin fields for "part" app
This commit is contained in:
parent
cde85a5168
commit
e83b5f9db0
@ -8,10 +8,9 @@ from import_export.resources import ModelResource
|
|||||||
from import_export.fields import Field
|
from import_export.fields import Field
|
||||||
import import_export.widgets as widgets
|
import import_export.widgets as widgets
|
||||||
|
|
||||||
import part.models as models
|
|
||||||
|
|
||||||
from stock.models import StockLocation
|
|
||||||
from company.models import SupplierPart
|
from company.models import SupplierPart
|
||||||
|
import part.models as models
|
||||||
|
from stock.models import StockLocation
|
||||||
|
|
||||||
|
|
||||||
class PartResource(ModelResource):
|
class PartResource(ModelResource):
|
||||||
@ -76,6 +75,13 @@ class PartAdmin(ImportExportModelAdmin):
|
|||||||
|
|
||||||
search_fields = ('name', 'description', 'category__name', 'category__description', 'IPN')
|
search_fields = ('name', 'description', 'category__name', 'category__description', 'IPN')
|
||||||
|
|
||||||
|
autocomplete_fields = [
|
||||||
|
'variant_of',
|
||||||
|
'category',
|
||||||
|
'default_location',
|
||||||
|
'default_supplier',
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
class PartCategoryResource(ModelResource):
|
class PartCategoryResource(ModelResource):
|
||||||
""" Class for managing PartCategory data import/export """
|
""" Class for managing PartCategory data import/export """
|
||||||
@ -105,13 +111,6 @@ class PartCategoryResource(ModelResource):
|
|||||||
models.PartCategory.objects.rebuild()
|
models.PartCategory.objects.rebuild()
|
||||||
|
|
||||||
|
|
||||||
class PartCategoryInline(admin.TabularInline):
|
|
||||||
"""
|
|
||||||
Inline for PartCategory model
|
|
||||||
"""
|
|
||||||
model = models.PartCategory
|
|
||||||
|
|
||||||
|
|
||||||
class PartCategoryAdmin(ImportExportModelAdmin):
|
class PartCategoryAdmin(ImportExportModelAdmin):
|
||||||
|
|
||||||
resource_class = PartCategoryResource
|
resource_class = PartCategoryResource
|
||||||
@ -120,35 +119,44 @@ class PartCategoryAdmin(ImportExportModelAdmin):
|
|||||||
|
|
||||||
search_fields = ('name', 'description')
|
search_fields = ('name', 'description')
|
||||||
|
|
||||||
inlines = [
|
autocomplete_fields = ('parent', 'default_location',)
|
||||||
PartCategoryInline,
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
class PartRelatedAdmin(admin.ModelAdmin):
|
class PartRelatedAdmin(admin.ModelAdmin):
|
||||||
''' Class to manage PartRelated objects '''
|
"""
|
||||||
pass
|
Class to manage PartRelated objects
|
||||||
|
"""
|
||||||
|
|
||||||
|
autocomplete_fields = ('part_1', 'part_2')
|
||||||
|
|
||||||
|
|
||||||
class PartAttachmentAdmin(admin.ModelAdmin):
|
class PartAttachmentAdmin(admin.ModelAdmin):
|
||||||
|
|
||||||
list_display = ('part', 'attachment', 'comment')
|
list_display = ('part', 'attachment', 'comment')
|
||||||
|
|
||||||
|
autocomplete_fields = ('part',)
|
||||||
|
|
||||||
|
|
||||||
class PartStarAdmin(admin.ModelAdmin):
|
class PartStarAdmin(admin.ModelAdmin):
|
||||||
|
|
||||||
list_display = ('part', 'user')
|
list_display = ('part', 'user')
|
||||||
|
|
||||||
|
autocomplete_fields = ('part',)
|
||||||
|
|
||||||
|
|
||||||
class PartCategoryStarAdmin(admin.ModelAdmin):
|
class PartCategoryStarAdmin(admin.ModelAdmin):
|
||||||
|
|
||||||
list_display = ('category', 'user')
|
list_display = ('category', 'user')
|
||||||
|
|
||||||
|
autocomplete_fields = ('category',)
|
||||||
|
|
||||||
|
|
||||||
class PartTestTemplateAdmin(admin.ModelAdmin):
|
class PartTestTemplateAdmin(admin.ModelAdmin):
|
||||||
|
|
||||||
list_display = ('part', 'test_name', 'required')
|
list_display = ('part', 'test_name', 'required')
|
||||||
|
|
||||||
|
autocomplete_fields = ('part',)
|
||||||
|
|
||||||
|
|
||||||
class BomItemResource(ModelResource):
|
class BomItemResource(ModelResource):
|
||||||
""" Class for managing BomItem data import/export """
|
""" Class for managing BomItem data import/export """
|
||||||
@ -253,10 +261,14 @@ class BomItemAdmin(ImportExportModelAdmin):
|
|||||||
|
|
||||||
search_fields = ('part__name', 'part__description', 'sub_part__name', 'sub_part__description')
|
search_fields = ('part__name', 'part__description', 'sub_part__name', 'sub_part__description')
|
||||||
|
|
||||||
|
autocomplete_fields = ('part', 'sub_part',)
|
||||||
|
|
||||||
|
|
||||||
class ParameterTemplateAdmin(ImportExportModelAdmin):
|
class ParameterTemplateAdmin(ImportExportModelAdmin):
|
||||||
list_display = ('name', 'units')
|
list_display = ('name', 'units')
|
||||||
|
|
||||||
|
search_fields = ('name', 'units')
|
||||||
|
|
||||||
|
|
||||||
class ParameterResource(ModelResource):
|
class ParameterResource(ModelResource):
|
||||||
""" Class for managing PartParameter data import/export """
|
""" Class for managing PartParameter data import/export """
|
||||||
@ -282,10 +294,12 @@ class ParameterAdmin(ImportExportModelAdmin):
|
|||||||
|
|
||||||
list_display = ('part', 'template', 'data')
|
list_display = ('part', 'template', 'data')
|
||||||
|
|
||||||
|
autocomplete_fields = ('part', 'template')
|
||||||
|
|
||||||
|
|
||||||
class PartCategoryParameterAdmin(admin.ModelAdmin):
|
class PartCategoryParameterAdmin(admin.ModelAdmin):
|
||||||
|
|
||||||
pass
|
autocomplete_fields = ('category', 'parameter_template',)
|
||||||
|
|
||||||
|
|
||||||
class PartSellPriceBreakAdmin(admin.ModelAdmin):
|
class PartSellPriceBreakAdmin(admin.ModelAdmin):
|
||||||
@ -303,6 +317,8 @@ class PartInternalPriceBreakAdmin(admin.ModelAdmin):
|
|||||||
|
|
||||||
list_display = ('part', 'quantity', 'price',)
|
list_display = ('part', 'quantity', 'price',)
|
||||||
|
|
||||||
|
autocomplete_fields = ('part',)
|
||||||
|
|
||||||
|
|
||||||
admin.site.register(models.Part, PartAdmin)
|
admin.site.register(models.Part, PartAdmin)
|
||||||
admin.site.register(models.PartCategory, PartCategoryAdmin)
|
admin.site.register(models.PartCategory, PartCategoryAdmin)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user