from django import forms from ra.admin.admin import ra_admin_site, RaAdmin, RaMovementAdmin from .models import Client, Product, SimpleSales class ClientAdmin(RaAdmin): fields = ('slug', 'title', 'notes', 'address', 'email', 'telephone') view_template = 'sales/admin/client_view.html' class ProductAdmin(RaAdmin): pass class SalesOrderAdmin(RaMovementAdmin): fields = [ 'slug', 'doc_date', 'client', ('product', 'price', 'quantity', 'value') ] add_form_template = change_form_template = 'sales/admin/salesorder_changeform.html' def formfield_for_dbfield(self, db_field, request, **kwargs): formfield = super().formfield_for_dbfield(db_field, request, **kwargs) if db_field.name == 'value': formfield.widget = forms.TextInput(attrs={'readonly': 'readonly'}) return formfield ra_admin_site.register(Client, ClientAdmin) ra_admin_site.register(Product, ProductAdmin) ra_admin_site.register(SimpleSales, SalesOrderAdmin)
<span class="legitRipple-ripple"></span></a>""" % (url, _('Recover')) return mark_safe(link) return '' review.short_description = _('review') def changelist_view(self, request, extra_context=None): extra_context = { 'has_detached_sidebar': True } return super(LogEntryAdmin, self).changelist_view(request, extra_context) class MyActivityAdmin(LogEntryAdmin): list_filter = [ ActionFilter, RAContentTypeFilter, ] def get_queryset(self, request): qs = super(MyActivityAdmin, self).get_queryset(request) qs = qs.filter(user_id=request.user.pk) return qs ra_admin_site.register(LogEntry, LogEntryAdmin) ra_admin_site.register(MyActivity, MyActivityAdmin)
from ra.admin.admin import EntityAdmin, TransactionAdmin, ra_admin_site from .models import Expense, ExpenseTransaction class ExpenseAdmin(EntityAdmin): pass class ExpenseTransactionAdmin(TransactionAdmin): fields = ('slug', 'doc_date', 'treasury', 'expense', 'value', 'notes') ra_admin_site.register(Expense, ExpenseAdmin) ra_admin_site.register(ExpenseTransaction, ExpenseTransactionAdmin)
from .models import Client, Product, SimpleSales, Invoice, InvoiceLine, JournalItem, Journal class ClientAdmin(RaAdmin): view_template = 'client_view.html' class ProductAdmin(RaAdmin): pass class SimpleSalesAdmin(RaMovementAdmin): pass ra_admin_site.register(Client, ClientAdmin) ra_admin_site.register(Product, ProductAdmin) ra_admin_site.register(SimpleSales, SimpleSalesAdmin) class InvoiceLineAdmin(RaMovementInlineAdmin): fields = ['product', 'quantity', 'discount', 'value'] model = InvoiceLine autocomplete_fields = ['product'] class InvoiceAdmin(RaMovementAdmin): fields = [('slug', 'doc_date'), 'client'] autocomplete_fields = ['client'] inlines = [InvoiceLineAdmin] copy_to_formset = ['client']
from ra.admin.admin import EntityAdmin, ra_admin_site from .models import Treasury class TreasuryAdmin(EntityAdmin): pass ra_admin_site.register(Treasury, TreasuryAdmin)