1
0
mirror of https://gitlab.crans.org/bde/nk20 synced 2024-12-29 10:52:20 +00:00
nk20/apps/treasury/admin.py

60 lines
1.6 KiB
Python
Raw Normal View History

2020-03-21 15:49:18 +00:00
# Copyright (C) 2018-2020 by BDE ENS Paris-Saclay
2020-03-24 16:06:50 +00:00
# SPDX-License-Identifier: GPL-3.0-or-lateré
2020-03-21 15:49:18 +00:00
from django.contrib import admin
from note_kfet.admin import admin_site
2020-07-30 13:53:23 +00:00
from .forms import ProductForm
2020-08-06 19:51:53 +00:00
from .models import RemittanceType, Remittance, SogeCredit, Invoice, Product
2020-03-21 15:49:18 +00:00
@admin.register(RemittanceType, site=admin_site)
2020-03-24 16:06:50 +00:00
class RemittanceTypeAdmin(admin.ModelAdmin):
"""
Admin customisation for RemiitanceType
"""
list_display = ('note', )
2020-03-21 15:49:18 +00:00
@admin.register(Remittance, site=admin_site)
2020-03-24 16:06:50 +00:00
class RemittanceAdmin(admin.ModelAdmin):
"""
Admin customisation for Remittance
"""
list_display = ('remittance_type', 'date', 'comment', 'count', 'amount', 'closed', )
def has_change_permission(self, request, obj=None):
if not obj:
return True
return not obj.closed and super().has_change_permission(request, obj)
2020-08-01 13:13:29 +00:00
@admin.register(SogeCredit, site=admin_site)
class SogeCreditAdmin(admin.ModelAdmin):
"""
Admin customisation for Remittance
"""
list_display = ('user', 'valid',)
readonly_fields = ('transactions', 'credit_transaction',)
def has_add_permission(self, request):
# Don't create a credit manually
return False
2020-08-06 19:51:53 +00:00
class ProductInline(admin.StackedInline):
"""
Inline product in invoice admin
"""
model = Product
form = ProductForm
@admin.register(Invoice, site=admin_site)
class InvoiceAdmin(admin.ModelAdmin):
"""
Admin customisation for Invoice
"""
list_display = ('object', 'id', 'bde', 'name', 'date', 'acquitted',)
inlines = (ProductInline,)