Do not save avatar cache if the record is not yet committed

This commit is contained in:
Cédric Krier
2021-03-28 20:32:09 +02:00
parent 4d0a6fa864
commit 2cdd2f28ff
+3 -1
View File
@@ -95,7 +95,9 @@ class Avatar(ImageMixin, ResourceMixin, ModelSQL):
if PIL:
with Transaction().new_transaction():
cache = self._store_cache(size, self._resize(size))
cache.save()
# Save cache only if record is already committed
if self.__class__.search([('id', '=', self.id)]):
cache.save()
return cache.image
else:
return self.image