From 2b0dcbc3c9eea802afffe9389a7abed234b9b284 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Mon, 20 Feb 2023 23:03:59 +0100 Subject: [PATCH] Reset cache when restore history of ModelSQL Closes #5086 --- trytond/trytond/model/modelsql.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/trytond/trytond/model/modelsql.py b/trytond/trytond/model/modelsql.py index 3d3bd6f4e9..6981f96041 100644 --- a/trytond/trytond/model/modelsql.py +++ b/trytond/trytond/model/modelsql.py @@ -643,6 +643,14 @@ class ModelSQL(ModelStorage): cursor = transaction.connection.cursor() table = cls.__table__() history = cls.__table_history__() + + transaction.counter += 1 + for cache in transaction.cache.values(): + if cls.__name__ in cache: + cache_cls = cache[cls.__name__] + for id_ in ids: + cache_cls.pop(id_, None) + columns = [] hcolumns = [] fnames = sorted(n for n, f in cls._fields.items()