[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).
This commit is contained in:
qsm-odoo
2019-03-04 17:05:01 +01:00
parent 232da9a0ec
commit fdb9f8273b
2 changed files with 22 additions and 1 deletions
+2 -1
View File
@@ -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
@@ -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 () {},
},
]
);