From 96d7fd67e1fdc002f47416288d6ea4ba8191e999 Mon Sep 17 00:00:00 2001 From: FrancoisGe Date: Tue, 2 Aug 2022 07:21:51 +0000 Subject: [PATCH] [FIX] web: duplicate translation alert Before this commit, it is possible to have duplicate field names in an alert translation. How: - enable multi-language - go to a form view with at least one translatable field - edit the value of that field - click on save (the translate alert displays the field name once) - edit the same field a second time - click on save Result Before: The translate alert displays the field name twice. Result After: The translate alert displays the field name once. closes odoo/odoo#97287 Signed-off-by: Aaron Bohy (aab) --- addons/web/static/src/views/form/form_controller.js | 4 +++- addons/web/static/tests/views/form/form_view_tests.js | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/addons/web/static/src/views/form/form_controller.js b/addons/web/static/src/views/form/form_controller.js index e0dd5f65142..870134b5da0 100644 --- a/addons/web/static/src/views/form/form_controller.js +++ b/addons/web/static/src/views/form/form_controller.js @@ -371,7 +371,9 @@ export class FormController extends Component { computeTranslateAlert() { if (this.shouldShowTranslateAlert) { this.translateAlertData[this.model.root.resId] = new Set([ - ...(this.translateAlertData[this.model.root.resId] || []), + ...(this.translateAlertData[this.model.root.resId] + ? toRaw(this.translateAlertData[this.model.root.resId]) + : []), ...this.model.root.dirtyTranslatableFields, ]); } diff --git a/addons/web/static/tests/views/form/form_view_tests.js b/addons/web/static/tests/views/form/form_view_tests.js index 568c8bb71c2..69e857c31a9 100644 --- a/addons/web/static/tests/views/form/form_view_tests.js +++ b/addons/web/static/tests/views/form/form_view_tests.js @@ -7833,7 +7833,8 @@ QUnit.module("Views", (hooks) => { ); await clickEdit(target); - await editInput(target, '[name="display_name"] input', "test2"); + await editInput(target, '[name="foo"] input', "test2"); + await editInput(target, '[name="display_name"] input', "test3"); await clickSave(target); assert.containsN( target,