From babbe363b6390fd7cbcc9d9f8db14716e0d2cc02 Mon Sep 17 00:00:00 2001 From: Romain Derie Date: Fri, 3 Apr 2020 08:51:05 +0000 Subject: [PATCH] [FIX] website_theme_install: do not write view arch if it was modified During theme install, theme.ir.ui.view are copied as ir.ui.view for the requested website. During theme update, those already created ir.ui.view will receive the theme.ir.ui.view modifications, including the `arch`, even if it was changed by the user, meaning the user changes would be lost. Here are some examples which will be wiped away when the theme is updated (only if the view is loaded from the theme module): - Changes made from website HTML/CSS/JS editor. - Changes made from website builder e.g. Theme modify footer with XPath and user make changes in footer then user changes will be gone on theme update - Changes made directly in the arch of ir.ui.view in the backend. This commit fixes that behavior by not updating views which were modified by the user. closes odoo/odoo#49224 X-original-commit: 9906e1d403c4e9137a0313c342a455f425e95b8e Signed-off-by: Romain Derie Co-authored-by: Romain Derie Co-authored-by: Kishan Gajjar --- addons/website/models/ir_module_module.py | 2 ++ addons/website/tests/test_views.py | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/addons/website/models/ir_module_module.py b/addons/website/models/ir_module_module.py index 86286a9fd2c..705c0b44316 100644 --- a/addons/website/models/ir_module_module.py +++ b/addons/website/models/ir_module_module.py @@ -162,6 +162,8 @@ class IrModuleModule(models.Model): # at update, ignore active field if 'active' in rec_data: rec_data.pop('active') + if model_name == 'ir.ui.view' and (find.arch_updated or find.arch == rec_data['arch']): + rec_data.pop('arch') find.update(rec_data) self._post_copy(rec, find) else: diff --git a/addons/website/tests/test_views.py b/addons/website/tests/test_views.py index 6abcef13aaf..9f19cdcc303 100644 --- a/addons/website/tests/test_views.py +++ b/addons/website/tests/test_views.py @@ -1309,3 +1309,11 @@ class TestThemeViews(common.TransactionCase): specific_main_view_children = specific_main_view.inherit_children_ids self.assertEqual(specific_main_view_children.name, 'Test Child View', "Ensure theme.ir.ui.view has been loaded as an ir.ui.view into the website..") self.assertEqual(specific_main_view_children.website_id, website_1, "..and the website is the correct one.") + + # 4. Keep User arch changes + new_arch = 'Odoo' + specific_main_view_children.arch = new_arch + theme_view.name = 'Test Child View modified' + test_theme_module.with_context(load_all_views=True)._theme_load(website_1) + self.assertEqual(specific_main_view_children.arch, new_arch, "View arch shouldn't have been overrided on theme update as it was modified by user.") + self.assertEqual(specific_main_view_children.name, 'Test Child View modified', "View should receive modification on theme update.")