From 789a515b9ee7aa9bf4b73e24d956e62ef4c91b69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Wed, 6 Nov 2024 17:57:35 +0100 Subject: [PATCH] Clear view caches when dashboard fields of user are modified Closes #13662 (grafted from 23916deaf57fd2fcf7a35deec337fb9a8e479bec) --HG-- branch : 7.0 --- modules/dashboard/res.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/modules/dashboard/res.py b/modules/dashboard/res.py index ae09747d2f..f24ef2be71 100644 --- a/modules/dashboard/res.py +++ b/modules/dashboard/res.py @@ -1,7 +1,7 @@ # This file is part of Tryton. The COPYRIGHT file at the top level of # this repository contains the full copyright notices and license terms. -from trytond.model import fields -from trytond.pool import PoolMeta +from trytond.model import ModelView, fields +from trytond.pool import Pool, PoolMeta class User(metaclass=PoolMeta): @@ -27,3 +27,14 @@ class User(metaclass=PoolMeta): @staticmethod def default_dashboard_layout(): return 'square' + + @classmethod + def write(cls, *args): + pool = Pool() + View = pool.get('ir.ui.view') + super().write(*args) + for values in args[1:None:2]: + if values.keys() & {'dashboard_layout', 'dashboard_actions'}: + View._view_get_cache.clear() + ModelView._fields_view_get_cache.clear() + break