From 31e13fc7f7279a664b2e483614eceb16712370a2 Mon Sep 17 00:00:00 2001 From: Hugo LEVY-FALK Date: Sun, 15 Jul 2018 15:01:34 +0200 Subject: [PATCH] Message d'erreur du can_create de facture plus verbeux --- cotisations/models.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/cotisations/models.py b/cotisations/models.py index 7b4fcab3..8b2d5430 100644 --- a/cotisations/models.py +++ b/cotisations/models.py @@ -228,13 +228,13 @@ class Facture(RevMixin, AclMixin, FieldPermissionModelMixin, models.Model): :return: a message and a boolean which is True if the user can create an invoice or if the `options.allow_self_subscription` is set. """ - nb_payments = len(Paiement.find_allowed_payments(user_request)) - nb_articles = len(Article.find_allowed_articles(user_request)) - return ( - user_request.has_perm('cotisations.add_facture') - or (nb_payments*nb_articles), - _("You don't have the right to create an invoice.") - ) + if user_request.has_perm('cotisations.add_facture'): + return True, None + if len(Paiement.find_allowed_payments(user_request)) <= 0: + return False, _("There are no payment types which you can use.") + if len(Article.find_allowed_articles(user_request)): + return False, _("There are no article that you can buy.") + return True def __init__(self, *args, **kwargs): super(Facture, self).__init__(*args, **kwargs)