details:   https://code.tryton.org/tryton/commit/aa4a8bd85207
branch:    default
user:      Cédric Krier <[email protected]>
date:      Tue Aug 25 09:45:59 2026 +0200
description:
        Store only records count greater than 0 in the cache when delete records

        The existing cached count may be just an estimation so it is possible 
that more
        records are deleted.

        Closes #15038
diffstat:

 trytond/trytond/model/modelstorage.py |  3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diffs (13 lines):

diff -r e56328f60aa4 -r aa4a8bd85207 trytond/trytond/model/modelstorage.py
--- a/trytond/trytond/model/modelstorage.py     Thu Aug 06 13:09:48 2026 +0200
+++ b/trytond/trytond/model/modelstorage.py     Tue Aug 25 09:45:59 2026 +0200
@@ -521,7 +521,8 @@
                     'cache', 'count_clear', default=1000):
                 cls._count_cache.set(cls.__name__, None)
             else:
-                cls._count_cache.set(cls.__name__, count - len(records))
+                cls._count_cache.set(
+                    cls.__name__, max(count - len(records), 0))
 
         ids = [r.id for r in records]
         if cls.__name__ in transaction.delete_records:

Reply via email to