diff --git a/setup/web_ir_actions_act_view_reload/odoo/addons/web_ir_actions_act_view_reload b/setup/web_ir_actions_act_view_reload/odoo/addons/web_ir_actions_act_view_reload new file mode 120000 index 000000000000..7ce67dc50547 --- /dev/null +++ b/setup/web_ir_actions_act_view_reload/odoo/addons/web_ir_actions_act_view_reload @@ -0,0 +1 @@ +../../../../web_ir_actions_act_view_reload \ No newline at end of file diff --git a/setup/web_ir_actions_act_view_reload/setup.py b/setup/web_ir_actions_act_view_reload/setup.py new file mode 100644 index 000000000000..28c57bb64031 --- /dev/null +++ b/setup/web_ir_actions_act_view_reload/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +) diff --git a/web_ir_actions_act_view_reload/__init__.py b/web_ir_actions_act_view_reload/__init__.py index e69de29bb2d1..0650744f6bc6 100644 --- a/web_ir_actions_act_view_reload/__init__.py +++ b/web_ir_actions_act_view_reload/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/web_ir_actions_act_view_reload/__manifest__.py b/web_ir_actions_act_view_reload/__manifest__.py index 010c8af5a65b..e751b2f6ce33 100644 --- a/web_ir_actions_act_view_reload/__manifest__.py +++ b/web_ir_actions_act_view_reload/__manifest__.py @@ -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/*", + ], + }, } diff --git a/web_ir_actions_act_view_reload/models/__init__.py b/web_ir_actions_act_view_reload/models/__init__.py new file mode 100644 index 000000000000..12a5eaf6b500 --- /dev/null +++ b/web_ir_actions_act_view_reload/models/__init__.py @@ -0,0 +1 @@ +from . import ir_actions_act_view_reload diff --git a/web_ir_actions_act_view_reload/models/ir_actions_act_view_reload.py b/web_ir_actions_act_view_reload/models/ir_actions_act_view_reload.py new file mode 100644 index 000000000000..c93349520b6c --- /dev/null +++ b/web_ir_actions_act_view_reload/models/ir_actions_act_view_reload.py @@ -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" diff --git a/web_ir_actions_act_view_reload/static/src/js/web_ir_actions_act_view_reload.esm.js b/web_ir_actions_act_view_reload/static/src/js/web_ir_actions_act_view_reload.esm.js new file mode 100644 index 000000000000..99966cd505a8 --- /dev/null +++ b/web_ir_actions_act_view_reload/static/src/js/web_ir_actions_act_view_reload.esm.js @@ -0,0 +1,27 @@ +/** @odoo-module **/ +// Copyright 2017 - 2018 Modoolar +// Copyright 2018 Modoolar +// 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) + + // 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({}); + } + } + return Promise.resolve(); +} + +actionHandlersRegistry.add("ir.actions.act_view_reload", ir_actions_act_view_reload); diff --git a/web_ir_actions_act_view_reload/static/src/js/web_ir_actions_act_view_reload.js b/web_ir_actions_act_view_reload/static/src/js/web_ir_actions_act_view_reload.js deleted file mode 100644 index d096ccd14c27..000000000000 --- a/web_ir_actions_act_view_reload/static/src/js/web_ir_actions_act_view_reload.js +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright 2017 - 2018 Modoolar -// Copyright 2018 Modoolar -// 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"); - - 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); - } - - return this._super.apply(this, arguments); - }, - - /** - * Handle 'ir.actions.act_view_reload' action - * @returns {Promise} Resolved promise - */ - _executeReloadAction: function () { - var controller = this.getCurrentController(); - if (controller && controller.widget) { - controller.widget.reload(); - } - - return Promise.resolve(); - }, - }); -}); diff --git a/web_ir_actions_act_view_reload/views/web_ir_actions_act_view_reload.xml b/web_ir_actions_act_view_reload/views/web_ir_actions_act_view_reload.xml deleted file mode 100644 index cd156b0d8eba..000000000000 --- a/web_ir_actions_act_view_reload/views/web_ir_actions_act_view_reload.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - -