mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-05 01:16:27 +00:00
Le save est fait en post_save de l'objet vente
This commit is contained in:
parent
0cef20cf3e
commit
539c2c7d23
1 changed files with 4 additions and 2 deletions
|
@ -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)
|
||||
|
||||
|
|
Loading…
Reference in a new issue