From 6768e77f9b6899473fffb8a8ed20d93a9798f9c6 Mon Sep 17 00:00:00 2001 From: Huy Date: Tue, 19 Apr 2022 03:17:43 +0000 Subject: [PATCH] [FIX] website: allow editor users to edit theme views Currently, "Editor and Designer" can't edit the views which originate from a theme (which are copies from the theme `theme.ir.ui.view` records). This error is caused by [1], which is preventing the `arch_updated` field to be set to `True`, as this field is supposed to be set to `True` only on manual user change, not during module update. Indeed, restricted users don't have access to the themes records, making the overide raising an error. But there were actually no reason for this code to be executed outside module operation. Steps to reproduce: - Create any view in a theme module. For example: create a custom footer view. - As a "Editor and Designer" user, edit this view through the website builder. - An access right error is raised. [1]: https://github.com/odoo/odoo/commit/1eb7c577ecb31c2f0876b6dd76769e2b47802cb0 closes odoo/odoo#91255 X-original-commit: d2be8dc99eb99321be1172af447d5f2536c17364 Signed-off-by: Romain Derie (rde) --- addons/website/models/theme_models.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/addons/website/models/theme_models.py b/addons/website/models/theme_models.py index 7134ea287a3..f03921c3641 100644 --- a/addons/website/models/theme_models.py +++ b/addons/website/models/theme_models.py @@ -2,6 +2,7 @@ # Part of Odoo. See LICENSE file for full copyright and licensing details. import logging +import threading from odoo import api, fields, models from odoo.tools.translate import xml_translate from odoo.modules.module import get_resource_from_path @@ -342,6 +343,12 @@ class IrUiView(models.Model): theme_template_id = fields.Many2one('theme.ir.ui.view', copy=False) def write(self, vals): + # During a theme module update, theme views' copies receiving an arch + # update should not be considered as `arch_updated`, as this is not a + # user made change. + test_mode = getattr(threading.currentThread(), 'testing', False) + if not (test_mode or self.pool._init): + return super().write(vals) no_arch_updated_views = other_views = self.env['ir.ui.view'] for record in self: # Do not mark the view as user updated if original view arch is similar