diff --git a/addons/web/static/src/legacy/legacy_client_actions.js b/addons/web/static/src/legacy/legacy_client_actions.js index 37334e64bb7..d10dd9448c4 100644 --- a/addons/web/static/src/legacy/legacy_client_actions.js +++ b/addons/web/static/src/legacy/legacy_client_actions.js @@ -31,12 +31,13 @@ function registerClientAction(name, action) { for (const key in this.props) { if (key === "action" || key === "actionId") { continue; - } else if (key === "breadcrumbs") { - options[key] = breadcrumbsToLegacy(this.props[key]); } else { options[key] = this.props[key]; } } + if (this.env.config.breadcrumbs) { + options.breadcrumbs = breadcrumbsToLegacy(this.env.config.breadcrumbs); + } // always add user context to the action context this.user = useService("user"); diff --git a/addons/web/static/tests/webclient/actions/legacy_tests.js b/addons/web/static/tests/webclient/actions/legacy_tests.js index a813a315094..c0520d95d0f 100644 --- a/addons/web/static/tests/webclient/actions/legacy_tests.js +++ b/addons/web/static/tests/webclient/actions/legacy_tests.js @@ -444,7 +444,7 @@ QUnit.module("ActionManager", (hooks) => { QUnit.test("correctly transports legacy Props for doAction", async (assert) => { assert.expect(4); - let ID=0; + let ID = 0; const MyAction = AbstractAction.extend({ init() { this._super(...arguments); @@ -456,21 +456,52 @@ QUnit.module("ActionManager", (hooks) => { const link = document.createElement("a"); link.setAttribute("id", `client_${this.ID}`); link.addEventListener("click", () => { - this.do_action("testClientAction", { clear_breadcrumbs: true, props: { chain: "never break"}}); + this.do_action("testClientAction", { + clear_breadcrumbs: true, + props: { chain: "never break" }, + }); }); this.el.appendChild(link); return res; - } + }, }); core.action_registry.add("testClientAction", MyAction); registerCleanup(() => delete core.action_registry.map.testClientAction); const webClient = await createWebClient({ serverData }); await doAction(webClient, "testClientAction"); - assert.verifySteps(["id: 0 props: {\"breadcrumbs\":[]}"]); + assert.verifySteps(['id: 0 props: {"breadcrumbs":[]}']); await click(document.getElementById("client_0")); - assert.verifySteps(["id: 1 props: {\"chain\":\"never break\",\"breadcrumbs\":[]}"]); + assert.verifySteps(['id: 1 props: {"chain":"never break","breadcrumbs":[]}']); + }); + + QUnit.test("breadcrumbs are correct in stacked legacy client actions", async function (assert) { + const ClientAction = AbstractAction.extend({ + hasControlPanel: true, + async start() { + this.$el.addClass("client_action"); + return this._super(...arguments); + }, + getTitle() { + return "Blabla"; + }, + }); + core.action_registry.add("clientAction", ClientAction); + registerCleanup(() => delete core.action_registry.map.clientAction); + + const webClient = await createWebClient({ serverData }); + + await doAction(webClient, 3); + assert.containsOnce(webClient, ".o_list_view"); + assert.strictEqual($(webClient.el).find(".breadcrumb-item").text(), "Partners"); + + await doAction(webClient, { + type: "ir.actions.client", + tag: "clientAction", + }); + assert.containsOnce(webClient, ".client_action"); + assert.strictEqual($(webClient.el).find(".breadcrumb-item").text(), "PartnersBlabla"); }); });