From ec5059f353f95a224878d6772f865287f2c22eea Mon Sep 17 00:00:00 2001 From: Hubert Van De Walle Date: Wed, 20 Mar 2024 08:10:16 +0000 Subject: [PATCH] [FIX] web: prevent double translations in views Steps to reproduce ================== In 17: - Install hr_holidays,project - Switch the language to dutch - Go to project > three dots > Projectupdates We can see `x/y Genomen`, it should be `x/y Taken` Cause of the issue ================== The original term is Tasks. When loading the views, python translates them and changes Tasks to Taken. Owl then translates the template and transforms Taken to Genomen. Solution ======== Since the views are already translated, we don't need to translate them with owl. We can simply set the attribute t-translation to off on the view root node. opw-3787336 closes odoo/odoo#158627 X-original-commit: 454760e12145f8987e443d7776a614a5eb441feb Signed-off-by: Aaron Bohy (aab) Signed-off-by: Hubert Van De Walle --- addons/web/static/src/views/view_compiler.js | 1 + .../tests/views/form/form_compiler_tests.js | 16 ++++++++-------- .../tests/views/kanban/kanban_compiler_tests.js | 2 +- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/addons/web/static/src/views/view_compiler.js b/addons/web/static/src/views/view_compiler.js index 46efb8f954c..0faf254a61c 100644 --- a/addons/web/static/src/views/view_compiler.js +++ b/addons/web/static/src/views/view_compiler.js @@ -252,6 +252,7 @@ export class ViewCompiler { const root = this.templates[key].cloneNode(true); const child = this.compileNode(root, params); const newRoot = createElement("t", [child]); + newRoot.setAttribute("t-translation", "off"); return newRoot; } diff --git a/addons/web/static/tests/views/form/form_compiler_tests.js b/addons/web/static/tests/views/form/form_compiler_tests.js index e3e9a4cbbb6..e46896b8f90 100644 --- a/addons/web/static/tests/views/form/form_compiler_tests.js +++ b/addons/web/static/tests/views/form/form_compiler_tests.js @@ -38,7 +38,7 @@ QUnit.module("Form Compiler", (hooks) => { QUnit.test("properly compile simple div", async (assert) => { const arch = /*xml*/ `
lol
`; const expected = /*xml*/ ` - +
lol
@@ -52,7 +52,7 @@ QUnit.module("Form Compiler", (hooks) => { async (assert) => { const arch = /*xml*/ `