From 950b5739e1131a027b68adafffa82c0c525e5598 Mon Sep 17 00:00:00 2001 From: Ryan Cole Date: Tue, 9 Aug 2022 16:07:45 +1200 Subject: [PATCH] Migrate web_ir_actions_act_view_reload to 15.0 --- .../addons/web_ir_actions_act_view_reload | 1 + setup/web_ir_actions_act_view_reload/setup.py | 6 +++ web_ir_actions_act_view_reload/__init__.py | 1 + .../__manifest__.py | 10 ++-- .../models/__init__.py | 1 + .../models/ir_actions_act_view_reload.py | 7 +++ .../src/js/web_ir_actions_act_view_reload.js | 48 ++++++++----------- .../views/web_ir_actions_act_view_reload.xml | 20 -------- 8 files changed, 42 insertions(+), 52 deletions(-) create mode 120000 setup/web_ir_actions_act_view_reload/odoo/addons/web_ir_actions_act_view_reload create mode 100644 setup/web_ir_actions_act_view_reload/setup.py create mode 100644 web_ir_actions_act_view_reload/models/__init__.py create mode 100644 web_ir_actions_act_view_reload/models/ir_actions_act_view_reload.py delete mode 100644 web_ir_actions_act_view_reload/views/web_ir_actions_act_view_reload.xml 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.js b/web_ir_actions_act_view_reload/static/src/js/web_ir_actions_act_view_reload.js index d096ccd14c27..125186ec97b9 100644 --- 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 @@ -1,37 +1,27 @@ +/** @odoo-module **/ // 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"); +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); 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 @@ - - - -