From 31ba9a271fc6bebe798c4b4f6e6061692ada26d8 Mon Sep 17 00:00:00 2001 From: Hugo LEVY-FALK Date: Mon, 21 Jan 2019 20:52:28 +0100 Subject: [PATCH] Fix get_subscription of invoice. --- cotisations/models.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/cotisations/models.py b/cotisations/models.py index 7346a634..c6b7cd1c 100644 --- a/cotisations/models.py +++ b/cotisations/models.py @@ -242,14 +242,16 @@ class Facture(BaseInvoice): self.__original_control = self.control def get_subscription(self): + """Returns every subscription associated with this invoice.""" return Cotisation.objects.filter( vente__in=self.vente_set.filter( Q(type_cotisation='All') | - Q(type_cotisation='Cotisation') + Q(type_cotisation='Adhesion') ) ) def is_subscription(self): + """Returns True if this invoice contains at least one subscribtion.""" return bool(self.get_subscription()) def save(self, *args, **kwargs): @@ -257,14 +259,15 @@ class Facture(BaseInvoice): if not self.__original_valid and self.valid: send_mail_invoice(self) if self.is_subscription() \ - and not self.__original_control \ - and self.control \ - and CotisationsOption.get_cached_value('send_voucher_mail'): + and not self.__original_control \ + and self.control \ + and CotisationsOption.get_cached_value('send_voucher_mail'): send_mail_voucher(self) def __str__(self): return str(self.user) + ' ' + str(self.date) + @receiver(post_save, sender=Facture) def facture_post_save(**kwargs): """ @@ -795,7 +798,7 @@ class Paiement(RevMixin, AclMixin, models.Model): if payment_method is not None and use_payment_method: return payment_method.end_payment(invoice, request) - ## So make this invoice valid, trigger send mail + # So make this invoice valid, trigger send mail invoice.valid = True invoice.save()