37 lines
1.2 KiB
Python
37 lines
1.2 KiB
Python
from django.contrib import admin
|
|
from .models import Category, Product, Customer, Supplier, Sale, SaleItem, Purchase
|
|
|
|
@admin.register(Category)
|
|
class CategoryAdmin(admin.ModelAdmin):
|
|
list_display = ('name_en', 'name_ar', 'slug')
|
|
prepopulated_fields = {'slug': ('name_en',)}
|
|
|
|
@admin.register(Product)
|
|
class ProductAdmin(admin.ModelAdmin):
|
|
list_display = ('name_en', 'name_ar', 'sku', 'price', 'stock_quantity', 'category')
|
|
list_filter = ('category',)
|
|
search_fields = ('name_en', 'name_ar', 'sku')
|
|
|
|
@admin.register(Customer)
|
|
class CustomerAdmin(admin.ModelAdmin):
|
|
list_display = ('name', 'phone', 'email')
|
|
search_fields = ('name', 'phone')
|
|
|
|
@admin.register(Supplier)
|
|
class SupplierAdmin(admin.ModelAdmin):
|
|
list_display = ('name', 'contact_person', 'phone')
|
|
|
|
class SaleItemInline(admin.TabularInline):
|
|
model = SaleItem
|
|
extra = 1
|
|
|
|
@admin.register(Sale)
|
|
class SaleAdmin(admin.ModelAdmin):
|
|
list_display = ('id', 'customer', 'total_amount', 'created_at')
|
|
inlines = [SaleItemInline]
|
|
|
|
@admin.register(Purchase)
|
|
class PurchaseAdmin(admin.ModelAdmin):
|
|
list_display = ('id', 'supplier', 'total_amount', 'created_at')
|
|
list_filter = ('supplier', 'created_at')
|