100 lines
2.9 KiB
Python
100 lines
2.9 KiB
Python
"""Формы документов."""
|
|
from django import forms
|
|
from .models import (
|
|
CustomerOrder,
|
|
CustomerOrderItem,
|
|
SupplierOrder,
|
|
SupplierOrderItem,
|
|
CashInflow,
|
|
CashTransfer,
|
|
CashExpense,
|
|
)
|
|
from django.forms import inlineformset_factory
|
|
|
|
|
|
class CustomerOrderItemForm(forms.ModelForm):
|
|
class Meta:
|
|
model = CustomerOrderItem
|
|
fields = ("product", "price", "currency", "quantity")
|
|
widgets = {
|
|
"quantity": forms.NumberInput(attrs={"size": 3, "min": 0, "max": 99, "style": "width: 4ch"}),
|
|
}
|
|
|
|
|
|
class SupplierOrderItemForm(forms.ModelForm):
|
|
class Meta:
|
|
model = SupplierOrderItem
|
|
fields = ("product", "price", "currency", "quantity")
|
|
widgets = {
|
|
"quantity": forms.NumberInput(attrs={"size": 3, "min": 0, "max": 99, "style": "width: 4ch"}),
|
|
}
|
|
|
|
|
|
CustomerOrderItemFormSet = inlineformset_factory(
|
|
CustomerOrder,
|
|
CustomerOrderItem,
|
|
form=CustomerOrderItemForm,
|
|
fields=("product", "price", "currency", "quantity"),
|
|
extra=1,
|
|
can_delete=True,
|
|
)
|
|
|
|
SupplierOrderItemFormSet = inlineformset_factory(
|
|
SupplierOrder,
|
|
SupplierOrderItem,
|
|
form=SupplierOrderItemForm,
|
|
fields=("product", "price", "currency", "quantity"),
|
|
extra=1,
|
|
can_delete=True,
|
|
)
|
|
|
|
|
|
class CustomerOrderForm(forms.ModelForm):
|
|
class Meta:
|
|
model = CustomerOrder
|
|
fields = ("date", "number", "order_kind", "organization", "client", "author")
|
|
widgets = {
|
|
"date": forms.DateInput(attrs={"size": 10}),
|
|
"number": forms.TextInput(attrs={"size": 15, "maxlength": 15}),
|
|
}
|
|
|
|
|
|
class SupplierOrderForm(forms.ModelForm):
|
|
class Meta:
|
|
model = SupplierOrder
|
|
fields = ("date", "number", "organization", "supplier", "currency", "rate", "author")
|
|
widgets = {
|
|
"date": forms.DateInput(attrs={"size": 10}),
|
|
"number": forms.TextInput(attrs={"size": 15, "maxlength": 15}),
|
|
}
|
|
|
|
|
|
class CashInflowForm(forms.ModelForm):
|
|
class Meta:
|
|
model = CashInflow
|
|
fields = ("date", "number", "recipient", "amount", "customer_order", "comment", "author")
|
|
widgets = {
|
|
"date": forms.DateInput(attrs={"size": 10}),
|
|
"number": forms.TextInput(attrs={"size": 15, "maxlength": 15}),
|
|
}
|
|
|
|
|
|
class CashTransferForm(forms.ModelForm):
|
|
class Meta:
|
|
model = CashTransfer
|
|
fields = ("date", "number", "sender", "recipient", "amount", "comment", "author")
|
|
widgets = {
|
|
"date": forms.DateInput(attrs={"size": 10}),
|
|
"number": forms.TextInput(attrs={"size": 15, "maxlength": 15}),
|
|
}
|
|
|
|
|
|
class CashExpenseForm(forms.ModelForm):
|
|
class Meta:
|
|
model = CashExpense
|
|
fields = ("date", "number", "sender", "amount", "supplier_order", "comment", "author")
|
|
widgets = {
|
|
"date": forms.DateInput(attrs={"size": 10}),
|
|
"number": forms.TextInput(attrs={"size": 15, "maxlength": 15}),
|
|
}
|