changeset 8934bd9d77cd in trytond:default
details: https://hg.tryton.org/trytond?cmd=changeset&node=8934bd9d77cd
description:
        Do not save avatar cache if the record is not yet committed
diffstat:

 trytond/ir/avatar.py |  4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diffs (14 lines):

diff -r 58a87c08f63b -r 8934bd9d77cd trytond/ir/avatar.py
--- a/trytond/ir/avatar.py      Sun Mar 28 19:49:52 2021 +0200
+++ b/trytond/ir/avatar.py      Sun Mar 28 20:32:09 2021 +0200
@@ -95,7 +95,9 @@
         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

Reply via email to