From fdb9f8273be62d0a6d8051f7ca0a66cdf22ae5e7 Mon Sep 17 00:00:00 2001 From: qsm-odoo Date: Mon, 4 Mar 2019 13:06:09 +0100 Subject: [PATCH] [FIX] web_editor: stop using translated versions in HTML editor Since https://github.com/odoo/odoo/commit/5a030db3eb77b6d80187f8ae1a64303b2f50391d the HTML editor displayed the translated versions of the templates it allows to customize. So if the user edited and saved such a template, the non-translated version was saved with translated-version content. The behavior before the mentioned commit was: 1) Load all views the HTML editor allows to edit 2) Each time a view is displayed, re-make a RPC to load the view again The mentioned commit made this simpler by making: 1) Load all views the HTML editor allows to edit 2) Each time a view is displayed, simply show the previously loaded view ... the problem was that the step (2) of the old behavior was explicitly saying (client-side) to load the view's untranslated content. This commit makes step (1) always load the untranslated versions of the views (server-side). --- addons/web_editor/models/ir_ui_view.py | 3 ++- .../website/static/src/js/website.tour.rte.js | 20 +++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/addons/web_editor/models/ir_ui_view.py b/addons/web_editor/models/ir_ui_view.py index 3aa6bac4713..808297f7702 100644 --- a/addons/web_editor/models/ir_ui_view.py +++ b/addons/web_editor/models/ir_ui_view.py @@ -188,7 +188,8 @@ class IrUiView(models.Model): ``bundles=True`` returns also the asset bundles """ user_groups = set(self.env.user.groups_id) - views = self.with_context(active_test=False)._views_get(key, bundles=bundles) + View = self.with_context(active_test=False, lang=None) + views = View._views_get(key, bundles=bundles) views = views.filtered(lambda v: not v.groups_id or len(user_groups.intersection(v.groups_id))) return views diff --git a/addons/website/static/src/js/website.tour.rte.js b/addons/website/static/src/js/website.tour.rte.js index 7785441faa0..d4ddff476e7 100644 --- a/addons/website/static/src/js/website.tour.rte.js +++ b/addons/website/static/src/js/website.tour.rte.js @@ -151,6 +151,26 @@ tour.register('rte_translator', { }, { content: "check bis: placeholder translation", trigger: 'input[placeholder="test french placeholder"]', + }, { + content: "Open customize menu", + trigger: "#customize-menu > .dropdown-toggle", + }, { + content: "Open HTML editor", + trigger: "[data-action='ace']", + }, { + content: "Check that the editor is not showing translated content (1)", + trigger: '.ace_text-layer .ace_line:contains("an HTML")', + run: function (actions) { + var lineEscapedText = $(this.$anchor.text()).text(); + if (lineEscapedText !== "<b></b> is an HTML tag & is empty") { + console.error('The HTML editor should display the correct untranslated content'); + $('body').addClass('rte_translator_error'); + } + }, + }, { + content: "Check that the editor is not showing translated content (2)", + trigger: 'body:not(.rte_translator_error)', + run: function () {}, }, ] );