Fix snapshot diff update issue

This commit is contained in:
Edgar P. Burkhart 2022-05-22 11:14:05 +02:00
parent 0e60dfba27
commit 5d6f47b852
Signed by: edpibu
GPG key ID: 9833D3C5A25BD227

View file

@ -122,6 +122,13 @@ class Snapshot(models.Model):
self.diff = self.value - self.previous.value self.diff = self.value - self.previous.value
super().save(*args, **kwargs) super().save(*args, **kwargs)
try:
_next = self.__class__.objects.get(previous=self)
except self.__class__.DoesNotExist:
pass
else:
_next.save(only_super=True)
def delete(self, *args, only_super=False, **kwargs): def delete(self, *args, only_super=False, **kwargs):
if not only_super: if not only_super:
try: try: