mirror of
https://github.com/ae-utbm/sith.git
synced 2025-06-27 05:35:16 +00:00
improve counter admin pages
This commit is contained in:
parent
06090e0cd9
commit
9049d8779c
@ -41,6 +41,7 @@ class ProductAdmin(SearchModelAdmin):
|
|||||||
"profit",
|
"profit",
|
||||||
"archived",
|
"archived",
|
||||||
)
|
)
|
||||||
|
list_select_related = ("product_type",)
|
||||||
search_fields = ("name", "code")
|
search_fields = ("name", "code")
|
||||||
|
|
||||||
|
|
||||||
@ -81,20 +82,13 @@ class AccountDumpAdmin(admin.ModelAdmin):
|
|||||||
"customer",
|
"customer",
|
||||||
"warning_mail_sent_at",
|
"warning_mail_sent_at",
|
||||||
"warning_mail_error",
|
"warning_mail_error",
|
||||||
"dump_operation",
|
"dump_operation__date",
|
||||||
"amount",
|
"amount",
|
||||||
)
|
)
|
||||||
|
list_select_related = ("customer", "customer__user", "dump_operation")
|
||||||
autocomplete_fields = ("customer", "dump_operation")
|
autocomplete_fields = ("customer", "dump_operation")
|
||||||
list_filter = ("warning_mail_error",)
|
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)
|
@admin.register(Counter)
|
||||||
class CounterAdmin(admin.ModelAdmin):
|
class CounterAdmin(admin.ModelAdmin):
|
||||||
@ -113,11 +107,14 @@ class RefillingAdmin(SearchModelAdmin):
|
|||||||
"customer__account_id",
|
"customer__account_id",
|
||||||
"counter__name",
|
"counter__name",
|
||||||
)
|
)
|
||||||
|
list_filter = (("counter", admin.RelatedOnlyFieldListFilter),)
|
||||||
|
date_hierarchy = "date"
|
||||||
|
|
||||||
|
|
||||||
@admin.register(Selling)
|
@admin.register(Selling)
|
||||||
class SellingAdmin(SearchModelAdmin):
|
class SellingAdmin(SearchModelAdmin):
|
||||||
list_display = ("customer", "label", "unit_price", "quantity", "counter", "date")
|
list_display = ("customer", "label", "unit_price", "quantity", "counter", "date")
|
||||||
|
list_select_related = ("customer", "customer__user", "counter")
|
||||||
search_fields = (
|
search_fields = (
|
||||||
"customer__user__username",
|
"customer__user__username",
|
||||||
"customer__user__first_name",
|
"customer__user__first_name",
|
||||||
@ -126,6 +123,8 @@ class SellingAdmin(SearchModelAdmin):
|
|||||||
"counter__name",
|
"counter__name",
|
||||||
)
|
)
|
||||||
autocomplete_fields = ("customer", "seller")
|
autocomplete_fields = ("customer", "seller")
|
||||||
|
list_filter = (("counter", admin.RelatedOnlyFieldListFilter),)
|
||||||
|
date_hierarchy = "date"
|
||||||
|
|
||||||
|
|
||||||
@admin.register(Permanency)
|
@admin.register(Permanency)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user