Skip to content

Commit

Permalink
Migrate web_ir_actions_act_view_reload to 15.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanc-me committed Aug 9, 2022
1 parent d4ae466 commit 31fcecb
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 52 deletions.
6 changes: 6 additions & 0 deletions setup/web_ir_actions_act_view_reload/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import setuptools

setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)
1 change: 1 addition & 0 deletions web_ir_actions_act_view_reload/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
10 changes: 7 additions & 3 deletions web_ir_actions_act_view_reload/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,15 @@
"name": "Web Actions View Reload",
"summary": "Enables reload of the current view via ActionManager",
"category": "Web",
"version": "14.0.1.0.0",
"version": "15.0.1.0.0",
"license": "LGPL-3",
"author": "Modoolar, CorporateHub, Odoo Community Association (OCA)",
"author": "Modoolar, CorporateHub, Ryan Cole, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/web",
"depends": ["web"],
"data": ["views/web_ir_actions_act_view_reload.xml"],
"installable": True,
"assets": {
"web.assets_backend": [
"web_ir_actions_act_view_reload/static/src/*",
],
},
}
1 change: 1 addition & 0 deletions web_ir_actions_act_view_reload/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import ir_actions_act_view_reload
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from odoo import models


class IrActionsActViewReload(models.Model):
_name = "ir.actions.act_view_reload"
_inherit = "ir.actions.actions"
_description = "View Reload"
Original file line number Diff line number Diff line change
@@ -1,37 +1,27 @@
/** @odoo-module **/
// Copyright 2017 - 2018 Modoolar <[email protected]>
// Copyright 2018 Modoolar <[email protected]>
// License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).
odoo.define("web_ir_actions_act_view_reload.ir_actions_act_view_reload", function (
require
) {
"use strict";

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

ActionManager.include({
/**
* Intercept action handling to detect extra action type
* @override
*/
_handleAction: function (action, options) {
if (action.type === "ir.actions.act_view_reload") {
return this._executeReloadAction(action, options);
}
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)

return this._super.apply(this, arguments);
},
//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

/**
* Handle 'ir.actions.act_view_reload' action
* @returns {Promise} Resolved promise
*/
_executeReloadAction: function () {
var controller = this.getCurrentController();
if (controller && controller.widget) {
controller.widget.reload();
}
const controller = args.env.services.action.currentController;
if (controller) {
const {__legacy_widget__} = controller.getLocalState();
if (__legacy_widget__) {
__legacy_widget__.reload({});
}
}
return Promise.resolve();
}

return Promise.resolve();
},
});
});
actionHandlersRegistry.add("ir.actions.act_view_reload", ir_actions_act_view_reload);

This file was deleted.

0 comments on commit 31fcecb

Please sign in to comment.