details:   https://code.tryton.org/tryton/commit/dcdd89b6bc84
branch:    8.0
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
        (grafted from aa4a8bd85207b307b4aa075b105550e4ddae100f)
diffstat:

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

diffs (13 lines):

diff -r 6a9cdef17df8 -r dcdd89b6bc84 trytond/trytond/model/modelstorage.py
--- a/trytond/trytond/model/modelstorage.py     Tue Aug 25 09:46:47 2026 +0200
+++ b/trytond/trytond/model/modelstorage.py     Tue Aug 25 09:45:59 2026 +0200
@@ -497,7 +497,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