Le serveur gitlab sera inaccessible le mercredi 19 février 2020 de 13h à 14h pour une intervention de maintenance programmée.

Commit 42818cbe authored by detraz's avatar detraz

Fix bug send_mail + factorisation

parent 175e2170
...@@ -50,7 +50,7 @@ from machines.models import regen ...@@ -50,7 +50,7 @@ from machines.models import regen
from re2o.field_permissions import FieldPermissionModelMixin from re2o.field_permissions import FieldPermissionModelMixin
from re2o.mixins import AclMixin, RevMixin from re2o.mixins import AclMixin, RevMixin
from cotisations.utils import find_payment_method from cotisations.utils import send_mail_invoice, find_payment_method
from cotisations.validators import check_no_balance from cotisations.validators import check_no_balance
...@@ -242,7 +242,10 @@ def facture_post_save(**kwargs): ...@@ -242,7 +242,10 @@ def facture_post_save(**kwargs):
Synchronise the LDAP user after an invoice has been saved. Synchronise the LDAP user after an invoice has been saved.
""" """
facture = kwargs['instance'] facture = kwargs['instance']
is_created = kwargs['created']
user = facture.user user = facture.user
if is_created:
send_mail_invoice(facture)
user.ldap_sync(base=False, access_refresh=True, mac_refresh=False) user.ldap_sync(base=False, access_refresh=True, mac_refresh=False)
......
...@@ -89,7 +89,7 @@ def send_mail_invoice(invoice): ...@@ -89,7 +89,7 @@ def send_mail_invoice(invoice):
'Votre facture / Your invoice', 'Votre facture / Your invoice',
template.render(ctx), template.render(ctx),
GeneralOption.get_cached_value('email_from'), GeneralOption.get_cached_value('email_from'),
[invoice.user.email], [invoice.user.get_mail],
attachments=[('invoice.pdf', pdf, 'application/pdf')] attachments=[('invoice.pdf', pdf, 'application/pdf')]
) )
mail.send() mail.send()
...@@ -81,7 +81,7 @@ from .forms import ( ...@@ -81,7 +81,7 @@ from .forms import (
) )
from .tex import render_invoice from .tex import render_invoice
from .payment_methods.forms import payment_method_factory from .payment_methods.forms import payment_method_factory
from .utils import find_payment_method, send_mail_invoice from .utils import find_payment_method
@login_required @login_required
...@@ -148,8 +148,6 @@ def new_facture(request, user, userid): ...@@ -148,8 +148,6 @@ def new_facture(request, user, userid):
p.facture = new_invoice_instance p.facture = new_invoice_instance
p.save() p.save()
send_mail_invoice(new_invoice_instance)
return new_invoice_instance.paiement.end_payment( return new_invoice_instance.paiement.end_payment(
new_invoice_instance, new_invoice_instance,
request request
...@@ -848,8 +846,6 @@ def credit_solde(request, user, **_kwargs): ...@@ -848,8 +846,6 @@ def credit_solde(request, user, **_kwargs):
number=1 number=1
) )
send_mail_invoice(invoice)
return invoice.paiement.end_payment(invoice, request) return invoice.paiement.end_payment(invoice, request)
p = get_object_or_404(Paiement, is_balance=True) p = get_object_or_404(Paiement, is_balance=True)
return form({ return form({
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment