view: agregando forma de pago en formulario de compra.
This commit is contained in:
parent
7b74e4d381
commit
a636264e4f
@ -3,8 +3,9 @@ from django.forms.models import inlineformset_factory
|
||||
|
||||
from django.forms.widgets import DateInput, DateTimeInput
|
||||
|
||||
from .models import Sale, SaleLine, ReconciliationJar
|
||||
from .models import Sale, SaleLine, ReconciliationJar, PaymentMethods
|
||||
|
||||
readonly_number_widget = forms.NumberInput(attrs={'readonly': 'readonly'})
|
||||
|
||||
class ImportProductsForm(forms.Form):
|
||||
csv_file = forms.FileField()
|
||||
@ -34,10 +35,23 @@ class PurchaseLineForm(forms.ModelForm):
|
||||
"description",
|
||||
]
|
||||
|
||||
|
||||
class PurchaseSummaryForm(forms.Form):
|
||||
quantity_lines = forms.IntegerField(widget=forms.NumberInput(attrs={'readonly': 'readonly'}))
|
||||
quantity_products = forms.IntegerField(widget=forms.NumberInput(attrs={'readonly': 'readonly'}))
|
||||
ammount = forms.DecimalField(max_digits=10, decimal_places=2, widget=forms.NumberInput(attrs={'readonly': 'readonly'}))
|
||||
quantity_lines = forms.IntegerField(
|
||||
widget=readonly_number_widget
|
||||
)
|
||||
quantity_products = forms.IntegerField(
|
||||
widget=readonly_number_widget
|
||||
)
|
||||
ammount = forms.DecimalField(
|
||||
max_digits=10,
|
||||
decimal_places=2,
|
||||
widget=readonly_number_widget
|
||||
)
|
||||
payment_method = forms.ChoiceField(
|
||||
choices=PaymentMethods.choices,
|
||||
widget=forms.Select(attrs={'disabled': 'disabled'})
|
||||
)
|
||||
|
||||
LineaFormSet = inlineformset_factory(
|
||||
Sale,
|
||||
|
@ -13,8 +13,8 @@
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{{ summary_form }}
|
||||
<button id="add_line" type="button" onclick="add_line">Añadir Linea</button>
|
||||
{{ summary_form }}
|
||||
<br/><button name="form" type="submit" >Comprar</button>
|
||||
<script src="{% static 'js/add_line.js' %}"></script>
|
||||
<script src="{% static 'js/sale_summary.js' %}"></script>
|
||||
|
@ -19,6 +19,7 @@ def buy(request):
|
||||
if request.method == "POST":
|
||||
sale_form = PurchaseForm(request.POST)
|
||||
sale_linea_form = LineaFormSet(request.POST)
|
||||
sale_summary_form = PurchaseSummaryForm(request.POST)
|
||||
if sale_form.is_valid() and sale_linea_form.is_valid():
|
||||
sale = sale_form.save()
|
||||
lines = sale_linea_form.save(commit=False)
|
||||
|
Loading…
Reference in New Issue
Block a user