From 2cdd2f28ff62d449a77b2d2fc305a6731d6960b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Sun, 28 Mar 2021 20:32:09 +0200 Subject: [PATCH] Do not save avatar cache if the record is not yet committed --- trytond/ir/avatar.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/trytond/ir/avatar.py b/trytond/ir/avatar.py index e94eca8aeb..0d7c8910e5 100644 --- a/trytond/ir/avatar.py +++ b/trytond/ir/avatar.py @@ -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