# -*- coding: utf-8 -*- from django.contrib import admin from django_admin import AdvancedExportExcelModelAdmin, ReadOnlyModelAdmin from stock.models import StockInfo from utils.stock_utils import update_stock_info class StockInfoAdmin(AdvancedExportExcelModelAdmin, admin.ModelAdmin): # list_display = ('stock_id', 'vendorCode', 'vendorName', 'vendorProductId', 'vendorProductName', 'storeId', 'storeName', 'quantity', 'estimateQuantity', 'inventoryDate', 'totalQuantity', 'estimateDate', 'totalEstimateQuantity', 'costPrice', 'status', 'created_at', 'updated_at') list_display = ('vendorProductId', 'vendorProductName', 'inventoryDate', 'totalQuantity', 'estimateDate', 'totalEstimateQuantity', 'costPrice', 'updated_at') readonly_fields = ('stock_id', 'vendorCode', 'vendorName', 'vendorProductId', 'vendorProductName', 'storeId', 'storeName', 'quantity', 'estimateQuantity', 'status') def save_model(self, request, obj, form, change): obj.save() if obj.inventoryDate and obj.estimateDate: update_stock_info(obj) admin.site.register(StockInfo, StockInfoAdmin)