Split backend in applications
This commit is contained in:
parent
a0d0b5d594
commit
b05c3e6760
47 changed files with 1463 additions and 866 deletions
44
nummi/transaction/forms.py
Normal file
44
nummi/transaction/forms.py
Normal file
|
@ -0,0 +1,44 @@
|
|||
from category.models import Category
|
||||
from main.forms import NummiFileInput, NummiForm
|
||||
from Statement.models import Statement
|
||||
|
||||
from .models import Invoice, Transaction
|
||||
|
||||
|
||||
class TransactionForm(NummiForm):
|
||||
class Meta:
|
||||
model = Transaction
|
||||
fields = [
|
||||
"statement",
|
||||
"name",
|
||||
"value",
|
||||
"date",
|
||||
"real_date",
|
||||
"category",
|
||||
"trader",
|
||||
"payment",
|
||||
"description",
|
||||
]
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
_user = kwargs.get("user")
|
||||
_disable_statement = kwargs.pop("disable_statement", False)
|
||||
super().__init__(*args, **kwargs)
|
||||
self.fields["category"].queryset = Category.objects.filter(user=_user)
|
||||
self.fields["statement"].queryset = Statement.objects.filter(user=_user)
|
||||
if _disable_statement:
|
||||
self.fields["statement"].disabled = True
|
||||
|
||||
|
||||
class InvoiceForm(NummiForm):
|
||||
prefix = "invoice"
|
||||
|
||||
class Meta:
|
||||
model = Invoice
|
||||
fields = [
|
||||
"name",
|
||||
"file",
|
||||
]
|
||||
widgets = {
|
||||
"file": NummiFileInput,
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue