mirror of https://github.com/OCA/web.git
[MIG] web_ir_actions_act_multi: Migration to 15.0
parent
bf986d51d7
commit
7bad8e08c6
|
@ -0,0 +1 @@
|
||||||
|
from . import models
|
|
@ -8,11 +8,16 @@
|
||||||
"name": "Web Actions Multi",
|
"name": "Web Actions Multi",
|
||||||
"summary": "Enables triggering of more than one action on ActionManager",
|
"summary": "Enables triggering of more than one action on ActionManager",
|
||||||
"category": "Web",
|
"category": "Web",
|
||||||
"version": "13.0.1.0.0",
|
"version": "15.0.1.0.0",
|
||||||
"license": "LGPL-3",
|
"license": "LGPL-3",
|
||||||
"author": "Modoolar, " "CorporateHub, " "Odoo Community Association (OCA)",
|
"author": "Modoolar, " "CorporateHub, " "Odoo Community Association (OCA)",
|
||||||
"website": "https://github.com/OCA/web",
|
"website": "https://github.com/OCA/web",
|
||||||
"depends": ["web"],
|
"depends": ["web"],
|
||||||
"data": ["views/web_ir_actions_act_multi.xml"],
|
"data": ["security/ir.model.access.csv"],
|
||||||
|
"assets": {
|
||||||
|
"web.assets_backend": [
|
||||||
|
"web_ir_actions_act_multi/static/src/**/*.esm.js",
|
||||||
|
],
|
||||||
|
},
|
||||||
"installable": True,
|
"installable": True,
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
from . import ir_actions
|
|
@ -0,0 +1,15 @@
|
||||||
|
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||||
|
|
||||||
|
from odoo import fields, models
|
||||||
|
|
||||||
|
|
||||||
|
class IrActionsActMulti(models.Model):
|
||||||
|
_name = "ir.actions.act_multi"
|
||||||
|
_description = "Action Mulit"
|
||||||
|
_inherit = "ir.actions.actions"
|
||||||
|
_table = "ir_actions"
|
||||||
|
|
||||||
|
type = fields.Char(default="ir.actions.act_multi")
|
||||||
|
|
||||||
|
def _get_readable_fields(self):
|
||||||
|
return super()._get_readable_fields() | {"actions"}
|
|
@ -5,3 +5,4 @@
|
||||||
* Alexey Pelykh <alexey.pelykh@corphub.eu>
|
* Alexey Pelykh <alexey.pelykh@corphub.eu>
|
||||||
|
|
||||||
* Manuel Calero - Tecnativa
|
* Manuel Calero - Tecnativa
|
||||||
|
* Matias Peralta, Juan Rivero - Adhoc
|
||||||
|
|
|
@ -2,13 +2,12 @@ To use this functionality you need to return following action with list of actio
|
||||||
|
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
@api.multi
|
def foo(self):
|
||||||
def foo():
|
|
||||||
self.ensure_one()
|
self.ensure_one()
|
||||||
return {
|
return {
|
||||||
'type': 'ir.actions.act_multi',
|
'type': 'ir.actions.act_multi',
|
||||||
'actions': [
|
'actions': [
|
||||||
{'type': 'ir.actions.act_window_close'},
|
{'type': 'ir.actions.act_window_close'},
|
||||||
{'type': 'ir.actions.act_view_reload'},
|
{'type': 'ir.actions.client', 'tag': 'reload'},
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
|
||||||
|
crud_ir_actions_act_multi,access_ir_actions_act_multi,model_ir_actions_act_multi,,1,1,1,1
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
/** @odoo-module **/
|
||||||
|
|
||||||
|
import {registry} from "@web/core/registry";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle 'ir.actions.act_multi' action
|
||||||
|
* @param {object} action see _handleAction() parameters
|
||||||
|
* @returns {$.Promise}
|
||||||
|
*/
|
||||||
|
|
||||||
|
async function executeMultiAction({env, action}) {
|
||||||
|
return action.actions
|
||||||
|
.map((item) => {
|
||||||
|
return () => {
|
||||||
|
return env.services.action.doAction(item);
|
||||||
|
};
|
||||||
|
})
|
||||||
|
.reduce((prev, cur) => {
|
||||||
|
return prev.then(cur);
|
||||||
|
}, Promise.resolve());
|
||||||
|
}
|
||||||
|
|
||||||
|
registry.category("action_handlers").add("ir.actions.act_multi", executeMultiAction);
|
|
@ -1,43 +0,0 @@
|
||||||
// Copyright 2017 - 2018 Modoolar <info@modoolar.com>
|
|
||||||
// Copyright 2018 Brainbean Apps <hello@brainbeanapps.com>
|
|
||||||
// Copyright 2020 Manuel Calero - Tecnativa
|
|
||||||
// License LGPLv3.0 or later (https://www.gnu.org/licenses/lgpl-3.0.en.html).
|
|
||||||
|
|
||||||
odoo.define("web_ir_actions_act_multi.ir_actions_act_multi", 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_multi") {
|
|
||||||
return this._executeMultiAction(action, options);
|
|
||||||
}
|
|
||||||
return this._super.apply(this, arguments);
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Handle 'ir.actions.act_multi' action
|
|
||||||
* @param {Object} action see _handleAction() parameters
|
|
||||||
* @param {Object} options see _handleAction() parameters
|
|
||||||
* @returns {$.Promise}
|
|
||||||
*/
|
|
||||||
_executeMultiAction: function(action, options) {
|
|
||||||
const self = this;
|
|
||||||
|
|
||||||
return action.actions
|
|
||||||
.map(item => {
|
|
||||||
return () => {
|
|
||||||
return self._handleAction(item, options);
|
|
||||||
};
|
|
||||||
})
|
|
||||||
.reduce((prev, cur) => {
|
|
||||||
return prev.then(cur);
|
|
||||||
}, Promise.resolve());
|
|
||||||
},
|
|
||||||
});
|
|
||||||
});
|
|
|
@ -1,19 +0,0 @@
|
||||||
<?xml version="1.0" encoding="utf-8" ?>
|
|
||||||
<!--
|
|
||||||
# Copyright 2017 - 2018 Modoolar <info@modoolar.com>
|
|
||||||
# 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_multi assets"
|
|
||||||
inherit_id="web.assets_backend"
|
|
||||||
>
|
|
||||||
<xpath expr="." position="inside">
|
|
||||||
<script
|
|
||||||
type="text/javascript"
|
|
||||||
src="/web_ir_actions_act_multi/static/src/js/web_ir_actions_act_multi.js"
|
|
||||||
/>
|
|
||||||
</xpath>
|
|
||||||
</template>
|
|
||||||
</odoo>
|
|
Loading…
Reference in New Issue