|
@@ -121,6 +121,14 @@ class Invoice(models.Model):
|
|
|
null=True, blank=True,
|
|
|
verbose_name='PDF')
|
|
|
|
|
|
+ def save(self, *args, **kwargs):
|
|
|
+ # First save to get a PK
|
|
|
+ super(Invoice, self).save(*args, **kwargs)
|
|
|
+ # Then use that pk to build draft invoice number
|
|
|
+ if not self.validated and self.pk and not self.number:
|
|
|
+ self.number = 'DRAFT-{}'.format(self.pk)
|
|
|
+ self.save()
|
|
|
+
|
|
|
def amount(self):
|
|
|
"""
|
|
|
Calcul le montant de la facture
|