Fix migration; fix invoice saving

This commit is contained in:
Edgar P. Burkhart 2022-12-31 18:44:03 +01:00
parent 2550c52a61
commit 748f9e5fb6
Signed by: edpibu
GPG key ID: 9833D3C5A25BD227
3 changed files with 11 additions and 16 deletions

View file

@ -279,11 +279,12 @@ class Invoice(CustomModel):
Transaction, on_delete=models.CASCADE, editable=False
)
def save(self):
def save(self, *args, **kwargs):
if Invoice.objects.filter(id=self.id).exists():
_prever = Invoice.objects.get(id=self.id)
if _prever.file and _prever.file != self.file:
pathlib.Path(_prever.file.path).unlink(missing_ok=True)
super().save(*args, **kwargs)
def __str__(self):
if hasattr(self, "transaction"):