Sélection par défaut de la caisse lorsqu'il n'y en a qu'une seule disponible

This commit is contained in:
Aurélien Delobelle 2016-09-05 20:07:08 +02:00
parent 3d2583e2a0
commit 468098ae7b
2 changed files with 10 additions and 2 deletions

View file

@ -1139,7 +1139,7 @@ $(document).ready(function() {
function hardReset(give_tri_focus=true) {
coolReset(give_tri_focus);
resetCheckout();
checkoutInput.trigger('change');
resetArticles();
khistory.reset();
resetSettings();

View file

@ -796,7 +796,15 @@ def kpsul(request):
data = {}
data['operationgroup_form'] = KPsulOperationGroupForm()
data['trigramme_form'] = KPsulAccountForm()
data['checkout_form'] = KPsulCheckoutForm()
initial = {}
try:
checkout = Checkout.objects.filter(
is_protected=False, valid_from__lte=timezone.now(),
valid_to__gte=timezone.now()).get()
initial['checkout'] = checkout
except Checkout.DoesNotExist, Checkout.MultipleObjectsReturned:
pass
data['checkout_form'] = KPsulCheckoutForm(initial=initial)
operation_formset = KPsulOperationFormSet(queryset=Operation.objects.none())
data['operation_formset'] = operation_formset
return render(request, 'kfet/kpsul.html', data)