From 90a5ad3046e2be12ba94b4a88fd4eafee0e03189 Mon Sep 17 00:00:00 2001 From: Daniel Reis Date: Wed, 2 Mar 2022 12:42:30 +0000 Subject: [PATCH] [FIX] base_user_role_company: wrong menus on re-login Issue found on logout / relogin. The user groups were applied correctly, but the main menu showed apps the user did not have access to. This was related to the menu caching mechanisn, that was disabled here. --- base_user_role_company/__init__.py | 1 + base_user_role_company/controllers/__init__.py | 1 + base_user_role_company/controllers/main.py | 16 ++++++++++++++++ 3 files changed, 18 insertions(+) create mode 100644 base_user_role_company/controllers/__init__.py create mode 100644 base_user_role_company/controllers/main.py diff --git a/base_user_role_company/__init__.py b/base_user_role_company/__init__.py index bb83730e9..efc2a3f33 100644 --- a/base_user_role_company/__init__.py +++ b/base_user_role_company/__init__.py @@ -1,4 +1,5 @@ # Copyright (C) 2021 Open Source Integrators # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +from . import controllers from . import models diff --git a/base_user_role_company/controllers/__init__.py b/base_user_role_company/controllers/__init__.py new file mode 100644 index 000000000..12a7e529b --- /dev/null +++ b/base_user_role_company/controllers/__init__.py @@ -0,0 +1 @@ +from . import main diff --git a/base_user_role_company/controllers/main.py b/base_user_role_company/controllers/main.py new file mode 100644 index 000000000..7df62870e --- /dev/null +++ b/base_user_role_company/controllers/main.py @@ -0,0 +1,16 @@ +# Copyright (C) 2022 Open Source Integrators +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import http + +from odoo.addons.web.controllers.main import Home + + +class HomeExtended(Home): + @http.route() + def web_load_menus(self, unique): + response = super().web_load_menus(unique) + # On logout & re-login we could see wrong menus being rendered + # To avoid this, menu http cache must be disabled + response.headers.remove("Cache-Control") + return response