8
0
Fork 0
mirror of https://gitlab2.federez.net/re2o/re2o synced 2024-11-05 01:16:27 +00:00

Autorise l'édition de facture si l'auto-souscription est interdite mais que l'on peut créer des factures.

This commit is contained in:
Hugo LEVY-FALK 2018-07-02 14:09:35 +02:00
parent d999089925
commit 32df64253b

View file

@ -99,22 +99,26 @@ def new_facture(request, user, userid):
) )
# Building the invocie form and the article formset # Building the invocie form and the article formset
is_self_subscription = False is_self_subscription = False
if not request.user.has_perm('cotisations.add_facture') and OptionalUser.get_cached_value('allow_self_subscription'): can_create_invoice = request.user.has_perm('cotisations.add_facture')
is_self_subscription = True allow_self_subscription = OptionalUser.get_cached_value('allow_self_subscription')
article_list = article_list.filter(allow_self_subscription=True) if not can_create_invoice:
allowed_payment = Paiement.objects.filter(allow_self_subscription=True) if allow_self_subscription:
invoice_form = NewFactureForm(request.POST or None, instance=invoice, allowed_payment=allowed_payment) is_self_subscription = True
elif not OptionalUser.get_cached_value('allow_self_subscription'): article_list = article_list.filter(allow_self_subscription=True)
messages.error( allowed_payment = Paiement.objects.filter(allow_self_subscription=True)
request, invoice_form = NewFactureForm(request.POST or None, instance=invoice, allowed_payment=allowed_payment)
_("You cannot subscribe. Please ask to the staff.") else:
) messages.error(
return redirect(reverse( request,
'users:profil', _("You cannot subscribe. Please ask to the staff.")
kwargs={'userid': userid} )
)) return redirect(reverse(
'users:profil',
kwargs={'userid': userid}
))
else: else:
invoice_form = NewFactureForm(request.POST or None, instance=invoice) invoice_form = NewFactureForm(request.POST or None, instance=invoice)
if request.user.is_class_club: if request.user.is_class_club:
article_formset = formset_factory(SelectClubArticleForm)( article_formset = formset_factory(SelectClubArticleForm)(
request.POST or None, request.POST or None,