From f70342f8256a8ffe36084ba691beb81171b74582 Mon Sep 17 00:00:00 2001 From: Konrad du Plessis Date: Fri, 24 Apr 2026 10:03:57 +0200 Subject: [PATCH] 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) --- core/admin.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/core/admin.py b/core/admin.py index e4d4fde..20026cf 100644 --- a/core/admin.py +++ b/core/admin.py @@ -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