diff --git a/addons/web/static/src/webclient/actions/action_service.js b/addons/web/static/src/webclient/actions/action_service.js index ce15406bd1d..5eb3fc6a321 100644 --- a/addons/web/static/src/webclient/actions/action_service.js +++ b/addons/web/static/src/webclient/actions/action_service.js @@ -1240,7 +1240,7 @@ function makeActionManager(env) { if (action.target !== "new") { const canProceed = await clearUncommittedChanges(env); if (!canProceed) { - return; + return new Promise(() => {}); } } return _executeActWindowAction(action, options); 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 6c343a5c2e2..9329c3a031d 100644 --- a/addons/web/static/tests/views/form/form_view_tests.js +++ b/addons/web/static/tests/views/form/form_view_tests.js @@ -1702,6 +1702,73 @@ QUnit.module("Views", (hooks) => { assert.hasClass(target.querySelector(".o_notebook .nav-link"), "active"); }); + QUnit.test( + "trying to leave an invalid form view should not change the navbar", + async function (assert) { + serverData.menus = { + root: { id: "root", children: [1, 2], name: "root", appID: "root" }, + 1: { id: 1, children: [], name: "App0", appID: 1, xmlid: "menu_3", actionID: 1 }, + 2: { id: 2, children: [], name: "App1", appID: 2, xmlid: "menu_3", actionID: 2 }, + }; + serverData.views = { + "partner,false,form": ` +
+ + + + +
`, + "product,false,list": '', + "product,false,search": "", + "partner,false,search": "", + }; + + serverData.actions = { + 1: { + id: 1, + name: "Partner", + res_model: "partner", + type: "ir.actions.act_window", + views: [[false, "form"]], + }, + 2: { + id: 2, + name: "Product", + res_model: "product", + type: "ir.actions.act_window", + views: [[false, "list"]], + }, + }; + + const target = getFixture(); + const webClient = await createWebClient({ serverData }); + + await doAction(webClient, 1); + assert.strictEqual( + target.querySelector(".o_main_navbar .o_menu_brand").textContent, + "App0" + ); + + await editInput(target, "[name='foo'] input", "blop"); + await click(target, ".o_navbar_apps_menu button"); + await click(target, ".o_navbar_apps_menu .dropdown-item[data-section='2']"); + await nextTick(); + assert.strictEqual( + target.querySelector(".o_main_navbar .o_menu_brand").textContent, + "App0" + ); + + await editInput(target, "[name='display_name'] input", "blop"); + await click(target, ".o_navbar_apps_menu button"); + await click(target, ".o_navbar_apps_menu .dropdown-item[data-section='2']"); + await nextTick(); + assert.strictEqual( + target.querySelector(".o_main_navbar .o_menu_brand").textContent, + "App1" + ); + } + ); + QUnit.test("rendering stat buttons with action", async function (assert) { assert.expect(3); diff --git a/addons/web/static/tests/views/list_view_tests.js b/addons/web/static/tests/views/list_view_tests.js index 8f315a8d6af..7e801c416c4 100644 --- a/addons/web/static/tests/views/list_view_tests.js +++ b/addons/web/static/tests/views/list_view_tests.js @@ -15357,7 +15357,8 @@ QUnit.module("Views", (hooks) => { await click(target.querySelector(".o_data_cell")); await editInput(target, '.o_data_cell [name="foo"] input', ""); - await doAction(webClient, 2); + doAction(webClient, 2); + await nextTick(); assert.deepEqual( [...target.querySelectorAll(".o_data_cell")].map((el) => el.textContent), ["", "blip", "gnap", "blip"]