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
This commit is contained in:
Cédric Krier committed 2026-08-25 09:45:59 +02:00
1 parent 8b3dfd63a9
commit dc73f174bd
1 file changed
+2 -1
+2 -1
View File
@@ -521,7 +521,8 @@ class ModelStorage(Model):
'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: