From dc73f174bd92bb7449497aee6e0e0c33c814d24c 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 --- 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 db86822fc7..30c184d0ae 100644 --- a/trytond/trytond/model/modelstorage.py +++ b/trytond/trytond/model/modelstorage.py @@ -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: