adding
This commit is contained in:
+59
-17
@@ -1,40 +1,82 @@
|
||||
from django.contrib import admin
|
||||
|
||||
from .models import Appointment, Customer, LedgerEntry, Product, StockMovement
|
||||
from .models import (
|
||||
Account,
|
||||
Customer,
|
||||
Invoice,
|
||||
InvoiceItem,
|
||||
LedgerEntry,
|
||||
LedgerInstallment,
|
||||
Product,
|
||||
StockMovement,
|
||||
Transaction,
|
||||
)
|
||||
|
||||
|
||||
@admin.register(Account)
|
||||
class AccountAdmin(admin.ModelAdmin):
|
||||
list_display = ("code", "name", "level", "account_type", "parent", "is_system", "is_active")
|
||||
list_filter = ("level", "account_type", "is_system", "is_active")
|
||||
search_fields = ("code", "name", "user__phone")
|
||||
autocomplete_fields = ["parent"]
|
||||
|
||||
|
||||
@admin.register(Customer)
|
||||
class CustomerAdmin(admin.ModelAdmin):
|
||||
list_display = ("name", "phone", "user", "updated_at")
|
||||
search_fields = ("name", "phone", "email", "user__phone")
|
||||
list_display = ("name", "phone", "outstanding_balance", "total_purchases_count", "last_purchase_date")
|
||||
search_fields = ("name", "phone", "user__phone")
|
||||
readonly_fields = (
|
||||
"total_purchases_count", "total_purchase_amount", "last_purchase_date", "outstanding_balance",
|
||||
)
|
||||
|
||||
|
||||
@admin.register(LedgerEntry)
|
||||
class LedgerEntryAdmin(admin.ModelAdmin):
|
||||
list_display = ("title", "entry_type", "amount", "entry_date", "user")
|
||||
list_display = ("title", "entry_type", "category", "amount", "entry_date", "counterparty_name")
|
||||
list_filter = ("entry_type", "category")
|
||||
search_fields = ("title", "user__phone")
|
||||
search_fields = ("title", "counterparty_name", "counterparty_phone", "user__phone")
|
||||
|
||||
|
||||
@admin.register(LedgerInstallment)
|
||||
class LedgerInstallmentAdmin(admin.ModelAdmin):
|
||||
list_display = ("ledger_entry", "amount", "paid_date", "reference")
|
||||
search_fields = ("reference", "ledger_entry__title")
|
||||
|
||||
|
||||
@admin.register(Product)
|
||||
class ProductAdmin(admin.ModelAdmin):
|
||||
list_display = ("name", "sku", "category", "quantity", "unit_price", "user")
|
||||
list_display = ("name", "sku", "category", "quantity", "unit", "unit_price", "total_purchase_value")
|
||||
list_filter = ("category",)
|
||||
search_fields = ("name", "sku", "user__phone")
|
||||
readonly_fields = ("total_purchase_value",)
|
||||
|
||||
|
||||
@admin.register(StockMovement)
|
||||
class StockMovementAdmin(admin.ModelAdmin):
|
||||
list_display = ("product", "delta", "quantity_after", "created_at")
|
||||
search_fields = ("product__name", "product__user__phone")
|
||||
readonly_fields = ("product", "delta", "quantity_after", "note", "created_at")
|
||||
|
||||
def has_add_permission(self, request):
|
||||
return False
|
||||
list_display = ("product", "delta", "quantity_after", "note", "created_at")
|
||||
search_fields = ("product__name",)
|
||||
|
||||
|
||||
@admin.register(Appointment)
|
||||
class AppointmentAdmin(admin.ModelAdmin):
|
||||
list_display = ("customer_name", "title", "start_at", "status", "user")
|
||||
list_filter = ("status",)
|
||||
search_fields = ("customer_name", "customer_phone", "user__phone")
|
||||
class InvoiceItemInline(admin.TabularInline):
|
||||
model = InvoiceItem
|
||||
extra = 0
|
||||
|
||||
|
||||
@admin.register(Invoice)
|
||||
class InvoiceAdmin(admin.ModelAdmin):
|
||||
list_display = (
|
||||
"invoice_number", "buyer_name", "final_amount", "payment_type", "payment_status", "order_status",
|
||||
"invoice_date",
|
||||
)
|
||||
list_filter = ("payment_type", "payment_status", "order_status")
|
||||
search_fields = ("invoice_number", "buyer_name", "buyer_phone", "user__phone")
|
||||
inlines = [InvoiceItemInline]
|
||||
|
||||
|
||||
@admin.register(Transaction)
|
||||
class TransactionAdmin(admin.ModelAdmin):
|
||||
list_display = (
|
||||
"transaction_number", "transaction_type", "debit_account", "credit_account", "amount", "transaction_date",
|
||||
)
|
||||
list_filter = ("transaction_type",)
|
||||
search_fields = ("transaction_number", "description", "user__phone")
|
||||
|
||||
Reference in New Issue
Block a user