[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) <dam@odoo.com>
This commit is contained in:
@@ -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',
|
||||
|
||||
|
||||
@@ -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/**/*',
|
||||
|
||||
@@ -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',
|
||||
|
||||
|
||||
@@ -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',
|
||||
|
||||
|
||||
@@ -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 };
|
||||
});
|
||||
}
|
||||
@@ -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);
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
@@ -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));
|
||||
|
||||
Reference in New Issue
Block a user