mirror of
https://github.com/inventree/InvenTree.git
synced 2025-05-02 21:38:48 +00:00
* fix list comps * mopre comp fixes * reduce computing cost on any() calls * add bugbear * check for clean imports * only allow limited relative imports * fix notification method lookup * fix notification method assigement * rewrite assigment * fix upstream changes to new style * fix upstream change to new coding style
105 lines
2.4 KiB
Python
105 lines
2.4 KiB
Python
"""Admin functionality for the BuildOrder app"""
|
|
|
|
from django.contrib import admin
|
|
|
|
from import_export.admin import ImportExportModelAdmin
|
|
from import_export.fields import Field
|
|
from import_export import widgets
|
|
|
|
from build.models import Build, BuildItem
|
|
from InvenTree.admin import InvenTreeResource
|
|
import part.models
|
|
|
|
|
|
class BuildResource(InvenTreeResource):
|
|
"""Class for managing import/export of Build data."""
|
|
# For some reason, we need to specify the fields individually for this ModelResource,
|
|
# but we don't for other ones.
|
|
# TODO: 2022-05-12 - Need to investigate why this is the case!
|
|
|
|
class Meta:
|
|
"""Metaclass options"""
|
|
models = Build
|
|
skip_unchanged = True
|
|
report_skipped = False
|
|
clean_model_instances = True
|
|
exclude = [
|
|
'lft', 'rght', 'tree_id', 'level',
|
|
'metadata',
|
|
]
|
|
|
|
id = Field(attribute='pk', widget=widgets.IntegerWidget())
|
|
|
|
reference = Field(attribute='reference')
|
|
|
|
title = Field(attribute='title')
|
|
|
|
part = Field(attribute='part', widget=widgets.ForeignKeyWidget(part.models.Part))
|
|
|
|
part_name = Field(attribute='part__full_name', readonly=True)
|
|
|
|
overdue = Field(attribute='is_overdue', readonly=True, widget=widgets.BooleanWidget())
|
|
|
|
completed = Field(attribute='completed', readonly=True)
|
|
|
|
quantity = Field(attribute='quantity')
|
|
|
|
status = Field(attribute='status')
|
|
|
|
batch = Field(attribute='batch')
|
|
|
|
notes = Field(attribute='notes')
|
|
|
|
|
|
class BuildAdmin(ImportExportModelAdmin):
|
|
"""Class for managing the Build model via the admin interface"""
|
|
|
|
exclude = [
|
|
'reference_int',
|
|
]
|
|
|
|
list_display = (
|
|
'reference',
|
|
'title',
|
|
'part',
|
|
'status',
|
|
'batch',
|
|
'quantity',
|
|
)
|
|
|
|
search_fields = [
|
|
'reference',
|
|
'title',
|
|
'part__name',
|
|
'part__description',
|
|
]
|
|
|
|
autocomplete_fields = [
|
|
'parent',
|
|
'part',
|
|
'sales_order',
|
|
'take_from',
|
|
'destination',
|
|
]
|
|
|
|
|
|
class BuildItemAdmin(admin.ModelAdmin):
|
|
"""Class for managing the BuildItem model via the admin interface"""
|
|
|
|
list_display = (
|
|
'build',
|
|
'stock_item',
|
|
'quantity'
|
|
)
|
|
|
|
autocomplete_fields = [
|
|
'build',
|
|
'bom_item',
|
|
'stock_item',
|
|
'install_into',
|
|
]
|
|
|
|
|
|
admin.site.register(Build, BuildAdmin)
|
|
admin.site.register(BuildItem, BuildItemAdmin)
|