From a8cd4e93157463badd38aa899609a4885d9b58f8 Mon Sep 17 00:00:00 2001 From: FrancoisGe Date: Mon, 22 Nov 2021 08:02:38 +0000 Subject: [PATCH] [FIX] web: Breadcrumb to FormView Before this commit, going to a form view using the breadcrumb menu did not retrieve the record id. The record id was not present in the url. So, if you reloaded the page, the record was not displayed anymore. closes odoo/odoo#80174 X-original-commit: 3eeaa6b1c6f54be9a87e67140ab57fe8f3a61407 Signed-off-by: Lucas Perais (lpe) --- .../src/webclient/actions/action_service.js | 2 +- .../webclient/actions/window_action_tests.js | 20 +++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/addons/web/static/src/webclient/actions/action_service.js b/addons/web/static/src/webclient/actions/action_service.js index 882c258631e..20662574854 100644 --- a/addons/web/static/src/webclient/actions/action_service.js +++ b/addons/web/static/src/webclient/actions/action_service.js @@ -1336,7 +1336,7 @@ function makeActionManager(env) { const props = controller.props; newState.model = props.resModel; newState.view_type = props.type; - newState.id = props.resId || undefined; + newState.id = props.resId || (props.state && props.state.currentId) || undefined; } env.services.router.pushState(newState, { replace: true }); } diff --git a/addons/web/static/tests/webclient/actions/window_action_tests.js b/addons/web/static/tests/webclient/actions/window_action_tests.js index 509924681ba..266f84e04c7 100644 --- a/addons/web/static/tests/webclient/actions/window_action_tests.js +++ b/addons/web/static/tests/webclient/actions/window_action_tests.js @@ -1329,6 +1329,26 @@ QUnit.module("ActionManager", (hooks) => { } ); + QUnit.test( + "form views are restored with the correct id in its url when coming back in breadcrumbs", + async function (assert) { + assert.expect(3); + const webClient = await createWebClient({ serverData }); + await doAction(webClient, 3); + // open a record in form view + await testUtils.dom.click($(webClient.el).find(".o_list_view .o_data_row:first")); + await legacyExtraNextTick(); + assert.strictEqual(webClient.env.services.router.current.hash.id, 1); + // do some other action + await doAction(webClient, 4); + assert.notOk(webClient.env.services.router.current.hash.id); + // go back to form view + await testUtils.dom.clickLast($(webClient.el).find(".o_control_panel .breadcrumb a")); + await legacyExtraNextTick(); + assert.strictEqual(webClient.env.services.router.current.hash.id, 1); + } + ); + QUnit.test("honor group_by specified in actions context", async function (assert) { assert.expect(5); serverData.actions[3].context = "{'group_by': 'bar'}";