mirror of
https://github.com/ae-utbm/sith.git
synced 2025-06-26 13:15:18 +00:00
Merge pull request #1138 from ae-utbm/counter-admin
improve counter admin pages
This commit is contained in:
commit
a7f4630d13
@ -41,6 +41,7 @@ class ProductAdmin(SearchModelAdmin):
|
||||
"profit",
|
||||
"archived",
|
||||
)
|
||||
list_select_related = ("product_type",)
|
||||
search_fields = ("name", "code")
|
||||
|
||||
|
||||
@ -81,20 +82,13 @@ class AccountDumpAdmin(admin.ModelAdmin):
|
||||
"customer",
|
||||
"warning_mail_sent_at",
|
||||
"warning_mail_error",
|
||||
"dump_operation",
|
||||
"dump_operation__date",
|
||||
"amount",
|
||||
)
|
||||
list_select_related = ("customer", "customer__user", "dump_operation")
|
||||
autocomplete_fields = ("customer", "dump_operation")
|
||||
list_filter = ("warning_mail_error",)
|
||||
|
||||
def get_queryset(self, request):
|
||||
# the `amount` property requires to know the customer and the dump_operation
|
||||
return (
|
||||
super()
|
||||
.get_queryset(request)
|
||||
.select_related("customer", "customer__user", "dump_operation")
|
||||
)
|
||||
|
||||
|
||||
@admin.register(Counter)
|
||||
class CounterAdmin(admin.ModelAdmin):
|
||||
@ -113,11 +107,14 @@ class RefillingAdmin(SearchModelAdmin):
|
||||
"customer__account_id",
|
||||
"counter__name",
|
||||
)
|
||||
list_filter = (("counter", admin.RelatedOnlyFieldListFilter),)
|
||||
date_hierarchy = "date"
|
||||
|
||||
|
||||
@admin.register(Selling)
|
||||
class SellingAdmin(SearchModelAdmin):
|
||||
list_display = ("customer", "label", "unit_price", "quantity", "counter", "date")
|
||||
list_select_related = ("customer", "customer__user", "counter")
|
||||
search_fields = (
|
||||
"customer__user__username",
|
||||
"customer__user__first_name",
|
||||
@ -126,6 +123,8 @@ class SellingAdmin(SearchModelAdmin):
|
||||
"counter__name",
|
||||
)
|
||||
autocomplete_fields = ("customer", "seller")
|
||||
list_filter = (("counter", admin.RelatedOnlyFieldListFilter),)
|
||||
date_hierarchy = "date"
|
||||
|
||||
|
||||
@admin.register(Permanency)
|
||||
|
Loading…
x
Reference in New Issue
Block a user