From eb14b26c7c49365f6eef9f2b287c2b383e81992e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Tue, 25 Aug 2026 09:45:59 +0200 Subject: [PATCH] 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 --- trytond/trytond/model/modelstorage.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/trytond/trytond/model/modelstorage.py b/trytond/trytond/model/modelstorage.py index 9dfab097d4..66f26f2e4f 100644 --- a/trytond/trytond/model/modelstorage.py +++ b/trytond/trytond/model/modelstorage.py @@ -497,7 +497,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: