mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-27 15:12:25 +00:00
Maj le dialup quand edition de facture
This commit is contained in:
parent
cb5df29e70
commit
ca0a6298bb
1 changed files with 27 additions and 0 deletions
|
@ -1,5 +1,7 @@
|
||||||
from django.db import models
|
from django.db import models
|
||||||
|
|
||||||
|
from django.db.models.signals import post_save, post_delete
|
||||||
|
from django.dispatch import receiver
|
||||||
from dateutil.relativedelta import relativedelta
|
from dateutil.relativedelta import relativedelta
|
||||||
from django.core.validators import MinValueValidator
|
from django.core.validators import MinValueValidator
|
||||||
|
|
||||||
|
@ -26,6 +28,17 @@ class Facture(models.Model):
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return str(self.date) + ' ' + str(self.user)
|
return str(self.date) + ' ' + str(self.user)
|
||||||
|
|
||||||
|
@receiver(post_save, sender=Facture)
|
||||||
|
def facture_post_save(sender, **kwargs):
|
||||||
|
facture = kwargs['instance']
|
||||||
|
user = facture.user
|
||||||
|
user.ldap_sync(base=False, access_refresh=True, mac_refresh=False)
|
||||||
|
|
||||||
|
@receiver(post_delete, sender=Facture)
|
||||||
|
def facture_post_delete(sender, **kwargs):
|
||||||
|
user = kwargs['instance'].user
|
||||||
|
user.ldap_sync(base=False, access_refresh=True, mac_refresh=False)
|
||||||
|
|
||||||
class Vente(models.Model):
|
class Vente(models.Model):
|
||||||
facture = models.ForeignKey('Facture', on_delete=models.CASCADE)
|
facture = models.ForeignKey('Facture', on_delete=models.CASCADE)
|
||||||
number = models.IntegerField(validators=[MinValueValidator(1)])
|
number = models.IntegerField(validators=[MinValueValidator(1)])
|
||||||
|
@ -46,6 +59,20 @@ class Vente(models.Model):
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return str(self.name) + ' ' + str(self.facture)
|
return str(self.name) + ' ' + str(self.facture)
|
||||||
|
|
||||||
|
@receiver(post_save, sender=Vente)
|
||||||
|
def vente_post_save(sender, **kwargs):
|
||||||
|
vente = kwargs['instance']
|
||||||
|
if vente.iscotisation:
|
||||||
|
user = vente.facture.user
|
||||||
|
user.ldap_sync(base=False, access_refresh=True, mac_refresh=False)
|
||||||
|
|
||||||
|
@receiver(post_delete, sender=Vente)
|
||||||
|
def vente_post_delete(sender, **kwargs):
|
||||||
|
vente = kwargs['instance']
|
||||||
|
if vente.iscotisation:
|
||||||
|
user = vente.facture.user
|
||||||
|
user.ldap_sync(base=False, access_refresh=True, mac_refresh=False)
|
||||||
|
|
||||||
class Article(models.Model):
|
class Article(models.Model):
|
||||||
name = models.CharField(max_length=255)
|
name = models.CharField(max_length=255)
|
||||||
prix = models.DecimalField(max_digits=5, decimal_places=2)
|
prix = models.DecimalField(max_digits=5, decimal_places=2)
|
||||||
|
|
Loading…
Reference in a new issue