2019-06-04 12:19:04 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
from __future__ import unicode_literals
|
|
|
|
|
|
|
|
from django.contrib import admin
|
2019-09-15 12:04:52 +00:00
|
|
|
|
2019-09-13 13:05:16 +00:00
|
|
|
from import_export.admin import ImportExportModelAdmin
|
2019-06-04 12:19:04 +00:00
|
|
|
|
2019-09-15 12:04:52 +00:00
|
|
|
from import_export.resources import ModelResource
|
|
|
|
from import_export.fields import Field
|
|
|
|
|
2019-06-04 12:19:04 +00:00
|
|
|
from .models import PurchaseOrder, PurchaseOrderLineItem
|
2020-04-20 10:27:35 +00:00
|
|
|
from .models import SalesOrder, SalesOrderLineItem
|
2020-04-22 03:11:19 +00:00
|
|
|
from .models import SalesOrderAllocation
|
2019-09-13 13:19:12 +00:00
|
|
|
|
2020-04-22 03:21:45 +00:00
|
|
|
|
2019-09-13 13:05:16 +00:00
|
|
|
class PurchaseOrderAdmin(ImportExportModelAdmin):
|
2019-06-04 12:19:04 +00:00
|
|
|
|
|
|
|
list_display = (
|
|
|
|
'reference',
|
2019-06-04 12:26:19 +00:00
|
|
|
'supplier',
|
2019-06-04 13:09:51 +00:00
|
|
|
'status',
|
2019-06-04 12:19:04 +00:00
|
|
|
'description',
|
|
|
|
'creation_date'
|
|
|
|
)
|
|
|
|
|
2020-09-29 13:41:50 +00:00
|
|
|
search_fields = [
|
|
|
|
'reference',
|
|
|
|
'supplier__name',
|
|
|
|
'description',
|
|
|
|
]
|
|
|
|
|
2019-06-04 12:19:04 +00:00
|
|
|
|
2020-04-20 10:27:35 +00:00
|
|
|
class SalesOrderAdmin(ImportExportModelAdmin):
|
|
|
|
|
|
|
|
list_display = (
|
|
|
|
'reference',
|
|
|
|
'customer',
|
|
|
|
'status',
|
|
|
|
'description',
|
|
|
|
'creation_date',
|
|
|
|
)
|
|
|
|
|
2020-09-29 13:41:50 +00:00
|
|
|
search_fields = [
|
|
|
|
'reference',
|
|
|
|
'customer__name',
|
|
|
|
'description',
|
|
|
|
]
|
|
|
|
|
2020-04-20 10:27:35 +00:00
|
|
|
|
2019-09-15 12:04:52 +00:00
|
|
|
class POLineItemResource(ModelResource):
|
|
|
|
""" Class for managing import / export of POLineItem data """
|
|
|
|
|
|
|
|
part_name = Field(attribute='part__part__name', readonly=True)
|
|
|
|
|
|
|
|
manufacturer = Field(attribute='part__manufacturer', readonly=True)
|
|
|
|
|
|
|
|
MPN = Field(attribute='part__MPN', readonly=True)
|
|
|
|
|
|
|
|
SKU = Field(attribute='part__SKU', readonly=True)
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
model = PurchaseOrderLineItem
|
|
|
|
skip_unchanged = True
|
|
|
|
report_skipped = False
|
|
|
|
clean_model_instances = True
|
|
|
|
|
|
|
|
|
2020-04-20 10:27:35 +00:00
|
|
|
class SOLineItemResource(ModelResource):
|
|
|
|
""" Class for managing import / export of SOLineItem data """
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
model = SalesOrderLineItem
|
|
|
|
skip_unchanged = True
|
|
|
|
report_skipped = False
|
|
|
|
clean_model_instances = True
|
|
|
|
|
|
|
|
|
2019-09-13 13:05:16 +00:00
|
|
|
class PurchaseOrderLineItemAdmin(ImportExportModelAdmin):
|
2019-06-04 12:19:04 +00:00
|
|
|
|
2019-09-15 12:04:52 +00:00
|
|
|
resource_class = POLineItemResource
|
|
|
|
|
2019-06-04 12:19:04 +00:00
|
|
|
list_display = (
|
|
|
|
'order',
|
2019-06-10 13:05:14 +00:00
|
|
|
'part',
|
2019-06-04 12:19:04 +00:00
|
|
|
'quantity',
|
|
|
|
'reference'
|
|
|
|
)
|
|
|
|
|
|
|
|
|
2020-04-20 10:27:35 +00:00
|
|
|
class SalesOrderLineItemAdmin(ImportExportModelAdmin):
|
|
|
|
|
|
|
|
resource_class = SOLineItemResource
|
|
|
|
|
|
|
|
list_display = (
|
|
|
|
'order',
|
2020-04-20 22:57:13 +00:00
|
|
|
'part',
|
2020-04-20 10:27:35 +00:00
|
|
|
'quantity',
|
|
|
|
'reference'
|
|
|
|
)
|
|
|
|
|
|
|
|
|
2020-04-22 03:11:19 +00:00
|
|
|
class SalesOrderAllocationAdmin(ImportExportModelAdmin):
|
|
|
|
|
|
|
|
list_display = (
|
|
|
|
'line',
|
|
|
|
'item',
|
|
|
|
'quantity'
|
|
|
|
)
|
|
|
|
|
|
|
|
|
2019-06-04 12:19:04 +00:00
|
|
|
admin.site.register(PurchaseOrder, PurchaseOrderAdmin)
|
|
|
|
admin.site.register(PurchaseOrderLineItem, PurchaseOrderLineItemAdmin)
|
2020-04-20 10:27:35 +00:00
|
|
|
|
|
|
|
admin.site.register(SalesOrder, SalesOrderAdmin)
|
|
|
|
admin.site.register(SalesOrderLineItem, SalesOrderLineItemAdmin)
|
2020-04-22 03:11:19 +00:00
|
|
|
|
|
|
|
admin.site.register(SalesOrderAllocation, SalesOrderAllocationAdmin)
|