From 9c1f704e596e7ba4a72f5ab579fe757711dabcff Mon Sep 17 00:00:00 2001 From: "Michael (mcm)" Date: Thu, 28 Sep 2023 08:55:11 +0200 Subject: [PATCH] [IMP] *: remove action service mapper This commit removes the event `do-action` listened on `core.bus` and adpats the place where it was triggered. task 3439226 closes odoo/odoo#137088 Related: odoo/enterprise#48144 Signed-off-by: Mathieu Duckerts-Antoine (dam) --- addons/mrp_subcontracting/__manifest__.py | 1 - addons/point_of_sale/__manifest__.py | 1 - addons/project/__manifest__.py | 1 - addons/web/__manifest__.py | 1 - addons/web/static/src/legacy/backend_utils.js | 62 ------------------- .../src/legacy/legacy_service_provider.js | 11 ---- addons/web/static/src/legacy/legacy_setup.js | 3 - 7 files changed, 80 deletions(-) delete mode 100644 addons/web/static/src/legacy/backend_utils.js diff --git a/addons/mrp_subcontracting/__manifest__.py b/addons/mrp_subcontracting/__manifest__.py index e090edcc95e..c56b68c0be0 100644 --- a/addons/mrp_subcontracting/__manifest__.py +++ b/addons/mrp_subcontracting/__manifest__.py @@ -150,7 +150,6 @@ 'web/static/src/legacy/legacy_promise_error_handler.js', 'web/static/src/legacy/legacy_rpc_error_handler.js', 'web/static/src/legacy/legacy_setup.js', - 'web/static/src/legacy/backend_utils.js', 'web/static/src/legacy/utils.js', 'web/static/src/legacy/js/env.js', diff --git a/addons/point_of_sale/__manifest__.py b/addons/point_of_sale/__manifest__.py index 0bd9ffd40aa..8d83037d964 100644 --- a/addons/point_of_sale/__manifest__.py +++ b/addons/point_of_sale/__manifest__.py @@ -160,7 +160,6 @@ 'web/static/src/legacy/js/**/*', ('remove', 'web/static/src/legacy/js/libs/**/*'), ('remove', 'web/static/src/legacy/js/public/**/*'), - 'web/static/src/legacy/backend_utils.js', 'web/static/src/legacy/legacy_service_provider.js', 'web/static/src/legacy/utils.js', 'web/static/src/search/**/*', diff --git a/addons/project/__manifest__.py b/addons/project/__manifest__.py index e2935f46823..c97593dd679 100644 --- a/addons/project/__manifest__.py +++ b/addons/project/__manifest__.py @@ -202,7 +202,6 @@ 'web/static/src/legacy/legacy_promise_error_handler.js', 'web/static/src/legacy/legacy_rpc_error_handler.js', 'web/static/src/legacy/legacy_setup.js', - 'web/static/src/legacy/backend_utils.js', 'web/static/src/legacy/utils.js', 'web/static/src/legacy/js/env.js', diff --git a/addons/web/__manifest__.py b/addons/web/__manifest__.py index 2537e872a43..0d9bed8c369 100644 --- a/addons/web/__manifest__.py +++ b/addons/web/__manifest__.py @@ -140,7 +140,6 @@ This module provides the core of the Odoo Web Client. 'web/static/src/legacy/legacy_service_provider.js', 'web/static/src/legacy/legacy_promise_error_handler.js', 'web/static/src/legacy/legacy_rpc_error_handler.js', - 'web/static/src/legacy/backend_utils.js', 'web/static/src/legacy/utils.js', 'web/static/src/legacy/js/env.js', diff --git a/addons/web/static/src/legacy/backend_utils.js b/addons/web/static/src/legacy/backend_utils.js deleted file mode 100644 index 1ed0c56b849..00000000000 --- a/addons/web/static/src/legacy/backend_utils.js +++ /dev/null @@ -1,62 +0,0 @@ -/** @odoo-module **/ - -function getGlobalState(legacyControllerState) { - const { resIds, searchPanel } = legacyControllerState; - const globalState = {}; - if (searchPanel) { - globalState.searchPanel = searchPanel; - } - if (resIds) { - globalState.resIds = resIds; - } - return globalState; -} - -export function mapDoActionOptionAPI(legacyOptions) { - legacyOptions = legacyOptions || {}; - // use camelCase instead of snake_case for some keys - Object.assign(legacyOptions, { - additionalContext: legacyOptions.additional_context, - clearBreadcrumbs: legacyOptions.clear_breadcrumbs, - viewType: legacyOptions.view_type, - onClose: legacyOptions.on_close, - props: Object.assign({ resId: legacyOptions.res_id }, legacyOptions.props), - }); - if (legacyOptions.controllerState) { - legacyOptions.props.globalState = getGlobalState(legacyOptions.controllerState); - } - delete legacyOptions.additional_context; - delete legacyOptions.clear_breadcrumbs; - delete legacyOptions.view_type; - delete legacyOptions.res_id; - delete legacyOptions.on_close; - return legacyOptions; -} - -export function makeLegacyActionManagerService(legacyEnv) { - // add a service to redirect 'do-action' events triggered on the bus in the - // legacy env to the action-manager service in the wowl env - return { - dependencies: ["action"], - start(env) { - function do_action(action, options) { - const legacyOptions = mapDoActionOptionAPI(options); - return env.services.action.doAction(action, legacyOptions); - } - legacyEnv.bus.on("do-action", null, (payload) => { - const { action, options } = payload; - do_action(action, options); - }); - return { do_action }; - }, - }; -} - -export function breadcrumbsToLegacy(breadcrumbs) { - if (!breadcrumbs) { - return; - } - return breadcrumbs.slice(0, -1).map((bc) => { - return { title: bc.name, controllerID: bc.jsId }; - }); -} diff --git a/addons/web/static/src/legacy/legacy_service_provider.js b/addons/web/static/src/legacy/legacy_service_provider.js index 73f42c8eac7..02996c04138 100644 --- a/addons/web/static/src/legacy/legacy_service_provider.js +++ b/addons/web/static/src/legacy/legacy_service_provider.js @@ -1,11 +1,9 @@ /** @odoo-module **/ import { bus } from "@web/legacy/js/services/core"; -import { makeContext } from "@web/core/context"; import { browser } from "../core/browser/browser"; import { registry } from "../core/registry"; -import { mapDoActionOptionAPI } from "./backend_utils"; export const legacyServiceProvider = { dependencies: ["effect", "action"], @@ -16,15 +14,6 @@ export const legacyServiceProvider = { bus.on("show-effect", this, (payload) => { services.effect.add(payload); }); - - browser.addEventListener("do-action", (ev) => { - const payload = ev.detail; - if (payload.action.context) { - payload.action.context = makeContext([payload.action.context]); - } - const legacyOptions = mapDoActionOptionAPI(payload.options); - services.action.doAction(payload.action, legacyOptions); - }); }, }; diff --git a/addons/web/static/src/legacy/legacy_setup.js b/addons/web/static/src/legacy/legacy_setup.js index b9c0c888df5..f1fbe8d876e 100644 --- a/addons/web/static/src/legacy/legacy_setup.js +++ b/addons/web/static/src/legacy/legacy_setup.js @@ -2,7 +2,6 @@ import { registry } from "../core/registry"; import { makeLegacyNotificationService } from "./utils"; -import { makeLegacyActionManagerService } from "./backend_utils"; import legacyEnv from "@web/legacy/js/env"; import { templates } from "@web/core/assets"; @@ -17,9 +16,7 @@ export const legacySetupProm = new Promise((resolve) => { // with the starting of the webclient) (async () => { Component.env = legacyEnv; - const legacyActionManagerService = makeLegacyActionManagerService(legacyEnv); const serviceRegistry = registry.category("services"); - serviceRegistry.add("legacy_action_manager", legacyActionManagerService); // add a service to redirect rpc events triggered on the bus in the // legacy env on the bus in the wowl env serviceRegistry.add("legacy_notification", makeLegacyNotificationService(legacyEnv));