details:   https://code.tryton.org/tryton/commit/8a24ddc59b2e
branch:    7.8
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 8dda4de1e3c7 -r 8a24ddc59b2e 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
@@ -470,7 +470,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