No Description

admin.py 1.3KB

    # -*- coding: utf-8 -*- from django.contrib import admin from django_admin import AdvancedExportExcelModelAdmin, ReadOnlyModelAdmin from stock.models import StockInfo from utils.redis.connect import r from utils.redis.rkeys import JDJOS_STOCK_CHANGED_SET 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 and ('inventoryDate' in form.changed_data or 'totalQuantity' in form.changed_data or 'estimateDate' in form.changed_data or 'totalEstimateQuantity' in form.changed_data or 'costPrice' in form.changed_data): r.sadd(JDJOS_STOCK_CHANGED_SET, obj.pk) admin.site.register(StockInfo, StockInfoAdmin)