|
@@ -116,12 +116,16 @@ class Invoice(models.Model):
|
|
|
Switch invoice to validate mode. This set to False the draft field
|
|
|
and generate the pdf
|
|
|
"""
|
|
|
- if not self.is_pdf_exists():
|
|
|
+ if not self.pdf_exists():
|
|
|
self.validated = True
|
|
|
self.save()
|
|
|
self.generate_pdf()
|
|
|
|
|
|
- def is_pdf_exists(self):
|
|
|
+ def save(self, *args, **kwargs):
|
|
|
+ self.number = Invoice.objects.get_next_invoice_number(self.date)
|
|
|
+ super(Invoice, self).save(*args, **kwargs)
|
|
|
+
|
|
|
+ def pdf_exists(self):
|
|
|
return (self.validated
|
|
|
and bool(self.pdf)
|
|
|
and private_files_storage.exists(self.pdf.name))
|