8
0
Fork 0
mirror of https://gitlab2.federez.net/re2o/re2o synced 2024-09-12 01:03:09 +00:00

Le save est fait en post_save de l'objet vente

This commit is contained in:
Gabriel Detraz 2017-09-27 17:50:11 +02:00 committed by root
parent 0cef20cf3e
commit 539c2c7d23

View file

@ -89,7 +89,6 @@ class Vente(models.Model):
if hasattr(self, 'cotisation'):
cotisation = self.cotisation
cotisation.date_end = cotisation.date_start + relativedelta(months=self.duration*self.number)
cotisation.save()
return
def create_cotis(self, date_start=False):
@ -105,7 +104,6 @@ class Vente(models.Model):
date_max = max(end_adhesion, date_start)
cotisation.date_start = date_max
cotisation.date_end = cotisation.date_start + relativedelta(months=self.duration*self.number)
cotisation.save()
return
def save(self, *args, **kwargs):
@ -121,8 +119,12 @@ class Vente(models.Model):
@receiver(post_save, sender=Vente)
def vente_post_save(sender, **kwargs):
vente = kwargs['instance']
if hasattr(vente, 'cotisation'):
vente.cotisation.vente = vente
vente.cotisation.save()
if vente.iscotisation:
vente.create_cotis()
vente.cotisation.save()
user = vente.facture.user
user.ldap_sync(base=False, access_refresh=True, mac_refresh=False)