Fix migration; fix invoice saving
This commit is contained in:
parent
2550c52a61
commit
748f9e5fb6
3 changed files with 11 additions and 16 deletions
|
@ -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"):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue