Skip to content

Commit

Permalink
web_ir_actions_act_view_reload: rewrite JS code
Browse files Browse the repository at this point in the history
  • Loading branch information
Ricardoalso committed Jan 17, 2025
1 parent a132d32 commit b76daf1
Showing 1 changed file with 8 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,16 @@
// License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).

import {registry} from "@web/core/registry";
const actionHandlersRegistry = registry.category("action_handlers");

function ir_actions_act_view_reload(args) {
// Odoo v15 is running in "legacy" mode - some of the JS
// is written in Owl, some is still legacy (e.g. controllers
// are still written in the old system - hence below hack)
export function irActionsActViewReload({env, action}) {
const currentController = env.services.action.currentController;

// TODO: for Odoo v16, this will probably need to be re-written in Owl
// REF: https://github.com/odoo/odoo/blob/7054fd6beb4f417efa4b22aafe8b935dd6ade123/addons/web/static/src/webclient/actions/action_service.js#L1257-L1267

const controller = args.env.services.action.currentController;
if (controller) {
const {__legacy_widget__} = controller.getLocalState();
if (__legacy_widget__) {
__legacy_widget__.reload({});
}
if (currentController) {
location.reload();
}

return Promise.resolve();
}

actionHandlersRegistry.add("ir.actions.act_view_reload", ir_actions_act_view_reload);
registry
.category("action_handlers")
.add("ir.actions.act_view_reload", irActionsActViewReload);

0 comments on commit b76daf1

Please sign in to comment.