forked from Techsystech/web
[MIG] web_ir_actions_act_view_reload: Migration to 15.0
parent
19a5d0f012
commit
add728cfba
|
@ -0,0 +1 @@
|
|||
from . import models
|
|
@ -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/**/*.esm.js",
|
||||
],
|
||||
},
|
||||
}
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
from . import ir_actions_act_view_reload
|
|
@ -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"
|
|
@ -0,0 +1,27 @@
|
|||
/** @odoo-module **/
|
||||
// Copyright 2017 - 2018 Modoolar <info@modoolar.com>
|
||||
// Copyright 2018 Modoolar <info@modoolar.com>
|
||||
// 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);
|
|
@ -1,37 +0,0 @@
|
|||
// Copyright 2017 - 2018 Modoolar <info@modoolar.com>
|
||||
// Copyright 2018 Modoolar <info@modoolar.com>
|
||||
// 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();
|
||||
},
|
||||
});
|
||||
});
|
|
@ -1,20 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<!--
|
||||
Copyright 2017 - 2018 Modoolar <info@modoolar.com>
|
||||
Copyright 2018 Brainbean Apps
|
||||
License LGPLv3.0 or later (https://www.gnu.org/licenses/lgpl-3.0.en.html).
|
||||
-->
|
||||
<odoo>
|
||||
<template
|
||||
id="assets_backend"
|
||||
name="web_ir_actions_act_view_reload assets"
|
||||
inherit_id="web.assets_backend"
|
||||
>
|
||||
<xpath expr="." position="inside">
|
||||
<script
|
||||
type="text/javascript"
|
||||
src="/web_ir_actions_act_view_reload/static/src/js/web_ir_actions_act_view_reload.js"
|
||||
/>
|
||||
</xpath>
|
||||
</template>
|
||||
</odoo>
|
Loading…
Reference in New Issue