diff --git a/addons/web/static/src/webclient/actions/action_service.js b/addons/web/static/src/webclient/actions/action_service.js index 9d1e0aec976..9776c354612 100644 --- a/addons/web/static/src/webclient/actions/action_service.js +++ b/addons/web/static/src/webclient/actions/action_service.js @@ -463,12 +463,12 @@ function makeActionManager(env) { resModel: action.res_model, type: view.type, selectRecord: async (resId, { activeIds, mode }) => { - if (_getView("form")) { + if (target !== "new" && _getView("form")) { await switchView("form", { mode, resId, resIds: activeIds }); } }, createRecord: async () => { - if (_getView("form")) { + if (target !== "new" && _getView("form")) { await switchView("form", { resId: false }); } }, diff --git a/addons/web/static/tests/webclient/actions/target_tests.js b/addons/web/static/tests/webclient/actions/target_tests.js index 01929b6c0cb..5eb98e69bff 100644 --- a/addons/web/static/tests/webclient/actions/target_tests.js +++ b/addons/web/static/tests/webclient/actions/target_tests.js @@ -475,6 +475,26 @@ QUnit.module("ActionManager", (hooks) => { assert.hasClass(target.querySelector(".o_dialog .modal-dialog"), "modal-xl"); }); + QUnit.test('click on record in list view action in target="new"', async function (assert) { + const webClient = await createWebClient({ serverData }); + await doAction(webClient, 1001); + await doAction(webClient, { + name: "Favorite Ponies", + res_model: "pony", + type: "ir.actions.act_window", + target: "new", + views: [[false, "list"], [false, "form"]], + }); + + // The list view has been opened in a dialog + assert.containsOnce(target, ".o_dialog .modal-dialog .o_list_view"); + + // click on a record in the dialog -> should do nothing as we can't switch view in the dialog + await click(target.querySelector(".modal .o_data_row .o_data_cell")); + assert.containsOnce(target, ".o_dialog .modal-dialog .o_list_view"); + assert.containsNone(target, ".o_form_view"); + }); + QUnit.module('Actions in target="fullscreen"'); QUnit.test(