diff --git a/addons/web/static/src/webclient/actions/action_service.js b/addons/web/static/src/webclient/actions/action_service.js index 5641569760e..b2048498b49 100644 --- a/addons/web/static/src/webclient/actions/action_service.js +++ b/addons/web/static/src/webclient/actions/action_service.js @@ -472,7 +472,23 @@ function makeActionManager(env) { throw error; } else { const lastCt = controllerStack[controllerStack.length - 1]; - const info = lastCt ? lastCt.__info__ : {}; + let info = {}; + if (lastCt) { + if (lastCt.jsId === controller.jsId) { + // the error occurred on the controller which is + // already in the DOM, so simply show the error + Promise.resolve().then(() => { + throw error; + }); + return; + } else { + info = lastCt.__info__; + // the error occurred while rendering a new controller, + // so go back to the last non faulty controller + // (the error will be shown anyway as the promise + // has been rejected) + } + } env.bus.trigger("ACTION_MANAGER:UPDATE", info); } } diff --git a/addons/web/static/tests/webclient/actions/client_action_tests.js b/addons/web/static/tests/webclient/actions/client_action_tests.js index 8eba3d7e52a..464114c0887 100644 --- a/addons/web/static/tests/webclient/actions/client_action_tests.js +++ b/addons/web/static/tests/webclient/actions/client_action_tests.js @@ -12,7 +12,6 @@ import { createWebClient, doAction, getActionManagerServerData } from "./../help const { Component, tags } = owl; let serverData; -const mainComponentRegistry = registry.category("main_components"); const actionRegistry = registry.category("actions"); QUnit.module("ActionManager", (hooks) => { diff --git a/addons/web/static/tests/webclient/actions/error_handling_tests.js b/addons/web/static/tests/webclient/actions/error_handling_tests.js index a156c48ba8a..fdea5e97213 100644 --- a/addons/web/static/tests/webclient/actions/error_handling_tests.js +++ b/addons/web/static/tests/webclient/actions/error_handling_tests.js @@ -1,7 +1,11 @@ /** @odoo-module **/ +import { browser } from "@web/core/browser/browser"; import { registry } from "@web/core/registry"; import { createWebClient, doAction, getActionManagerServerData } from "./../helpers"; +import { registerCleanup } from "../../helpers/cleanup"; +import { click, patchWithCleanup } from "../../helpers/utils"; +import { errorService } from "@web/core/errors/error_service"; const { Component, tags } = owl; @@ -15,7 +19,7 @@ QUnit.module("ActionManager", (hooks) => { QUnit.module("Error handling"); - QUnit.test("error in a client action", async function (assert) { + QUnit.test("error in a client action (at rendering)", async function (assert) { assert.expect(4); class Boom extends Component {} Boom.template = tags.xml`