From 04b3a890d463666bdd68ec25da8351327977c8df Mon Sep 17 00:00:00 2001 From: "Hubert Van de Walle (huvw)" Date: Fri, 9 Sep 2022 09:51:25 +0000 Subject: [PATCH] [FIX] web: duplicated breadcrumbs when discarding settings Steps to reproduce: - Go to settings - Click on discard -> the breadcrumbs contains twice the "Settings" entry. This commit fixes the issue by restoring the legacy behavior in the "Discard" button handler, that is, calling doActionButton with the special="cancel" param. This had been changed by mistake during the conversion of the settings form view. To make the fix work, a slight changed has been done in the model as well, as reloading a datapoint could lead to the creation of a new datapoint (typically when it's a new record), so the handle must be updated in this case. closes odoo/odoo#99904 Signed-off-by: Aaron Bohy (aab) --- .../src/views/basic_relational_model.js | 2 +- .../settings_form_controller.js | 1 + .../settings_form_view_tests.js | 28 +++++++------------ 3 files changed, 12 insertions(+), 19 deletions(-) diff --git a/addons/web/static/src/views/basic_relational_model.js b/addons/web/static/src/views/basic_relational_model.js index 68b3037e79c..a7ebde6028f 100644 --- a/addons/web/static/src/views/basic_relational_model.js +++ b/addons/web/static/src/views/basic_relational_model.js @@ -503,7 +503,7 @@ export class Record extends DataPoint { viewType: this.__viewType, }); } else { - await this.model.__bm__.reload(this.__bm_handle__, { + this.__bm_handle__ = await this.model.__bm__.reload(this.__bm_handle__, { viewType: this.__viewType, }); } diff --git a/addons/web/static/src/webclient/settings_form_view/settings_form_controller.js b/addons/web/static/src/webclient/settings_form_view/settings_form_controller.js index 1595be78e8e..75262fd17ae 100644 --- a/addons/web/static/src/webclient/settings_form_view/settings_form_controller.js +++ b/addons/web/static/src/webclient/settings_form_view/settings_form_controller.js @@ -110,6 +110,7 @@ export class SettingsFormController extends formView.Controller { clickParams: { name: "cancel", type: "object", + special: "cancel", }, getResParams: () => pick(this.model.root, "context", "evalContext", "resModel", "resId", "resIds"), diff --git a/addons/web/static/tests/webclient/settings_form_view/settings_form_view_tests.js b/addons/web/static/tests/webclient/settings_form_view/settings_form_view_tests.js index 4f5f0a4056c..c0d69232e3b 100644 --- a/addons/web/static/tests/webclient/settings_form_view/settings_form_view_tests.js +++ b/addons/web/static/tests/webclient/settings_form_view/settings_form_view_tests.js @@ -685,7 +685,7 @@ QUnit.module("SettingsFormView", (hooks) => { QUnit.test( "clicking on any button in setting should show discard warning if setting form is dirty", async function (assert) { - assert.expect(12); + assert.expect(11); serverData.actions = { 1: { @@ -735,10 +735,6 @@ QUnit.module("SettingsFormView", (hooks) => { assert.ok("execute method called"); return true; } - if (args.method === "cancel") { - assert.ok("cancel method called"); - return true; - } } }; @@ -1253,7 +1249,7 @@ QUnit.module("SettingsFormView", (hooks) => { } ); QUnit.test("Discard button clean the settings view", async function (assert) { - assert.expect(5); + assert.expect(10); serverData.actions = { 1: { @@ -1291,21 +1287,18 @@ QUnit.module("SettingsFormView", (hooks) => { }; const mockRPC = (route, args) => { - if (route === "/web/dataset/call_button" && args.method === "cancel") { - assert.step("cancel"); - return Promise.resolve({ - name: "Settings view", - res_model: "res.config.settings", - type: "ir.actions.act_window", - target: "inline", - views: [[false, "form"]], - }); - } + assert.step(args.method || route); }; const webClient = await createWebClient({ serverData, mockRPC }); await doAction(webClient, 1); + assert.verifySteps([ + "/web/webclient/load_menus", + "/web/action/load", + "get_views", + "onchange", + ]); assert.containsNone( target, ".o_field_boolean input:checked", @@ -1322,8 +1315,7 @@ QUnit.module("SettingsFormView", (hooks) => { ".o_field_boolean input:checked", "checkbox should not be checked" ); - - assert.verifySteps(["cancel"]); + assert.verifySteps(["onchange"]); }); QUnit.test("Settings Radio widget: show and search", async function (assert) {