forked from erp-dev/erp
38 lines
1.3 KiB
Python
38 lines
1.3 KiB
Python
from django.contrib import admin
|
|
|
|
from . import models
|
|
|
|
|
|
@admin.register(models.PurchaseOrder)
|
|
class PurchaseOrderAdmin(admin.ModelAdmin):
|
|
list_display = ('id', 'supplier', 'purchase_date', 'operator', 'created_at')
|
|
search_fields = ('supplier__name',)
|
|
list_filter = ('operator', 'warehouse', 'created_at')
|
|
ordering = ('-created_at',)
|
|
|
|
|
|
@admin.register(models.PurchaseOrderItem)
|
|
class PurchaseOrderItemAdmin(admin.ModelAdmin):
|
|
list_display = (
|
|
'id', 'purchase_order', 'product',
|
|
'quantity', 'unit', 'price', 'batch_number',
|
|
'_total_amount', 'empty_diff_percent',
|
|
'_real_quantity', '_diff_quantity',
|
|
'num_of_rolls',
|
|
)
|
|
search_fields = ('purchase_order__id', 'product__name')
|
|
list_filter = ('purchase_order__operator', 'purchase_order__warehouse', 'created_at')
|
|
ordering = ('-created_at',)
|
|
|
|
@admin.display(description='实际数量')
|
|
def _real_quantity(self, obj: models.PurchaseOrderItem):
|
|
return obj.real_quantity()
|
|
|
|
@admin.display(description='差异数量')
|
|
def _diff_quantity(self, obj: models.PurchaseOrderItem):
|
|
return obj.diff_quantity()
|
|
|
|
@admin.display(description='总金额')
|
|
def _total_amount(self, obj: models.PurchaseOrderItem):
|
|
return obj.total_amount()
|