From 605c2de5360d3b9518eaafa1963d967017925f34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20Gonz=C3=A1lez?= Date: Wed, 17 Nov 2021 21:50:57 +0000 Subject: [PATCH] [IMP] base: do nothardcode user fields that trigger cache invalidation Whenever a user is modified, if at least one of a predefinet-field list is being touched (e.g. companies or groups), cache is automatically invalidated. However, that field list is harcoded, which prevents it from being inherited and extended. This commit moves such fields to a separate method, which makes possible to inherit such method and extend the list. closes odoo/odoo#79986 Signed-off-by: Martin Trigaux (mat) --- odoo/addons/base/models/res_users.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/odoo/addons/base/models/res_users.py b/odoo/addons/base/models/res_users.py index 775206e1044..2b3490aa8c8 100644 --- a/odoo/addons/base/models/res_users.py +++ b/odoo/addons/base/models/res_users.py @@ -592,11 +592,7 @@ class Users(models.Model): # per-method / per-model caches have been removed so the various # clear_cache/clear_caches methods pretty much just end up calling # Registry._clear_cache - invalidation_fields = { - 'groups_id', 'active', 'lang', 'tz', 'company_id', - *USER_PRIVATE_FIELDS, - *self._get_session_token_fields() - } + invalidation_fields = self._get_invalidation_fields() if (invalidation_fields & values.keys()) or any(key.startswith('context_') for key in values): self.clear_caches() @@ -656,6 +652,14 @@ class Users(models.Model): def check_super(self, passwd): return check_super(passwd) + @api.model + def _get_invalidation_fields(self): + return { + 'groups_id', 'active', 'lang', 'tz', 'company_id', + *USER_PRIVATE_FIELDS, + *self._get_session_token_fields() + } + @api.model def _update_last_login(self): # only create new records to avoid any side-effect on concurrent transactions