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)

--HG--
branch : 8.0
This commit is contained in:
Cédric Krier
2026-08-25 09:45:59 +02:00
parent 32197c0397
commit eb14b26c7c
+2 -1
View File
@@ -497,7 +497,8 @@ class ModelStorage(Model):
'cache', 'count_clear', default=1000): 'cache', 'count_clear', default=1000):
cls._count_cache.set(cls.__name__, None) cls._count_cache.set(cls.__name__, None)
else: 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] ids = [r.id for r in records]
if cls.__name__ in transaction.delete_records: if cls.__name__ in transaction.delete_records: