[MIG] web_ir_actions_act_multi: Migration to 15.0

pull/2328/head
matiasperalta1 2021-12-23 14:44:51 -03:00
parent bf986d51d7
commit 7bad8e08c6
10 changed files with 52 additions and 67 deletions

View File

@ -0,0 +1 @@
from . import models

View File

@ -8,11 +8,16 @@
"name": "Web Actions Multi",
"summary": "Enables triggering of more than one action on ActionManager",
"category": "Web",
"version": "13.0.1.0.0",
"version": "15.0.1.0.0",
"license": "LGPL-3",
"author": "Modoolar, " "CorporateHub, " "Odoo Community Association (OCA)",
"website": "https://github.com/OCA/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,
}

View File

@ -0,0 +1 @@
from . import ir_actions

View File

@ -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"}

View File

@ -5,3 +5,4 @@
* Alexey Pelykh <alexey.pelykh@corphub.eu>
* Manuel Calero - Tecnativa
* Matias Peralta, Juan Rivero - Adhoc

View File

@ -2,13 +2,12 @@ To use this functionality you need to return following action with list of actio
.. code-block:: python
@api.multi
def foo():
def foo(self):
self.ensure_one()
return {
'type': 'ir.actions.act_multi',
'actions': [
{'type': 'ir.actions.act_window_close'},
{'type': 'ir.actions.act_view_reload'},
{'type': 'ir.actions.client', 'tag': 'reload'},
]
}

View File

@ -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
1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
2 crud_ir_actions_act_multi access_ir_actions_act_multi model_ir_actions_act_multi 1 1 1 1

View File

@ -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);

View File

@ -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());
},
});
});

View File

@ -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>