ux(admin): use display label in PayrollAdjustment admin list column
Code-review follow-up on 1cf1304. /admin/core/payrolladjustment/ was still showing raw DB values (New Loan / Advance Payment / Advance Repayment) in the Type list column because list_display was the bare field name 'type', which Django renders via str(obj.type). Added a @admin.display method that returns obj.get_type_display() and referenced it in list_display instead. Column header stays 'Type' and the column is still sortable by the underlying field. list_filter kept on 'type' (DB value) - filter sidebar correctness doesn't require the display label, and filtering works off the canonical stored value. Closes the last known "users see shorter labels everywhere" gap from the Path A rename. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
1cf13048c2
commit
f70342f825
@ -114,10 +114,19 @@ class LoanAdmin(admin.ModelAdmin):
|
||||
|
||||
@admin.register(PayrollAdjustment)
|
||||
class PayrollAdjustmentAdmin(admin.ModelAdmin):
|
||||
list_display = ('worker', 'type', 'amount', 'date')
|
||||
list_display = ('worker', 'type_display', 'amount', 'date')
|
||||
list_filter = ('type', 'date', 'worker')
|
||||
search_fields = ('worker__name', 'description')
|
||||
|
||||
# === Type column uses the short user-facing label ===
|
||||
@admin.display(description='Type', ordering='type')
|
||||
def type_display(self, obj):
|
||||
"""Show the short user-facing label (e.g. "Loan", "Advance")
|
||||
instead of the raw DB value ("New Loan", "Advance Payment").
|
||||
Sorting and filtering still work off the underlying `type`
|
||||
field — this only changes what's printed in the column."""
|
||||
return obj.get_type_display()
|
||||
|
||||
class ExpenseLineItemInline(admin.TabularInline):
|
||||
model = ExpenseLineItem
|
||||
extra = 1
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user