[MIG] web_ir_actions_act_window_message: Migration to 14.0

pull/2389/head
Koen Loodts 2020-12-07 20:21:54 +01:00 committed by miguels73
parent 8e8b13e448
commit 86f903839e
8 changed files with 48 additions and 14 deletions

View File

@ -113,6 +113,10 @@ Contributors
* Benjamin Willig (ACSONE SA/NV) <benjamin.willig@acsone.eu> * Benjamin Willig (ACSONE SA/NV) <benjamin.willig@acsone.eu>
* Ioan Galan (Studio73) <ioan@studio73.es> * Ioan Galan (Studio73) <ioan@studio73.es>
* Abraham Anes (Studio73) <abraham@studio73.es> * Abraham Anes (Studio73) <abraham@studio73.es>
* `DynApps NV <https://www.dynapps.be>`_:
* Koen Loodts
* Raf Ven
Maintainers Maintainers
~~~~~~~~~~~ ~~~~~~~~~~~
@ -127,6 +131,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and mission is to support the collaborative development of Odoo features and
promote its widespread use. promote its widespread use.
This module is part of the `OCA/web <https://github.com/OCA/web/tree/13.0/web_ir_actions_act_window_message>`_ project on GitHub. This module is part of the `OCA/web <https://github.com/OCA/web/tree/14.0/web_ir_actions_act_window_message>`_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

View File

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

View File

@ -2,12 +2,13 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{ {
"name": "Client side message boxes", "name": "Client side message boxes",
"version": "13.0.1.0.0", "version": "14.0.1.0.0",
"author": "Therp BV, " "ACSONE SA/NV, " "Odoo Community Association (OCA)", "author": "Therp BV, " "ACSONE SA/NV, " "Odoo Community Association (OCA)",
"website": "https://github.com/OCA/web",
"license": "AGPL-3", "license": "AGPL-3",
"category": "Hidden/Dependency", "category": "Hidden/Dependency",
"summary": "Show a message box to users", "summary": "Show a message box to users",
"depends": ["web"], "depends": ["web"],
"data": ["views/templates.xml"], "data": ["security/ir.model.access.csv", "views/templates.xml"],
"qweb": ["static/src/xml/web_ir_actions_act_window_message.xml"], "qweb": ["static/src/xml/web_ir_actions_act_window_message.xml"],
} }

View File

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

View File

@ -0,0 +1,21 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import fields, models
class IrActionsActWindowMessage(models.Model):
_name = "ir.actions.act_window.message"
_description = "Action Window Message"
_inherit = "ir.actions.actions"
_table = "ir_actions"
type = fields.Char(default="ir.actions.act_window.message")
def _get_readable_fields(self):
return super()._get_readable_fields() | {
"title",
"buttons",
"close_button_title",
"message",
"is_html_message",
}

View File

@ -3,3 +3,7 @@
* Benjamin Willig (ACSONE SA/NV) <benjamin.willig@acsone.eu> * Benjamin Willig (ACSONE SA/NV) <benjamin.willig@acsone.eu>
* Ioan Galan (Studio73) <ioan@studio73.es> * Ioan Galan (Studio73) <ioan@studio73.es>
* Abraham Anes (Studio73) <abraham@studio73.es> * Abraham Anes (Studio73) <abraham@studio73.es>
* `DynApps NV <https://www.dynapps.be>`_:
* Koen Loodts
* Raf Ven

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_window_message,access_ir_actions_act_window_message,model_ir_actions_act_window_message,,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_window_message access_ir_actions_act_window_message model_ir_actions_act_window_message 1 1 1 1

View File

@ -1,7 +1,7 @@
/* Copyright 2017 Therp BV, ACSONE SA/NV /* Copyright 2017 Therp BV, ACSONE SA/NV
* * License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). */ * * License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). */
odoo.define("web.web_ir_actions_act_window_message", function(require) { odoo.define("web.web_ir_actions_act_window_message", function (require) {
"use strict"; "use strict";
var ActionManager = require("web.ActionManager"), var ActionManager = require("web.ActionManager"),
@ -11,20 +11,20 @@ odoo.define("web.web_ir_actions_act_window_message", function(require) {
var _t = core._t; var _t = core._t;
ActionManager.include({ ActionManager.include({
_handleAction: function(action, options) { _handleAction: function (action, options) {
if (action.type === "ir.actions.act_window.message") { if (action.type === "ir.actions.act_window.message") {
return this._executeWindowMessageAction(action, options); return this._executeWindowMessageAction(action, options);
} }
return this._super.apply(this, arguments); return this._super.apply(this, arguments);
}, },
_executeWindowMessageAction: function(action, options) { _executeWindowMessageAction: function (action, options) {
var self = this, var self = this,
buttons = []; buttons = [];
if (action.close_button_title !== false) { if (action.close_button_title !== false) {
buttons.push({ buttons.push({
text: action.close_button_title || _t("Close"), text: action.close_button_title || _t("Close"),
click: function() { click: function () {
// Refresh the view before closing the dialog // Refresh the view before closing the dialog
var controller = self.getCurrentController(); var controller = self.getCurrentController();
if (controller && controller.widget) { if (controller && controller.widget) {
@ -61,7 +61,7 @@ odoo.define("web.web_ir_actions_act_window_message", function(require) {
buttons: buttons.concat( buttons: buttons.concat(
this.ir_actions_act_window_message_get_buttons( this.ir_actions_act_window_message_get_buttons(
action, action,
function() { function () {
dialog.close(); dialog.close();
} }
) )
@ -72,21 +72,21 @@ odoo.define("web.web_ir_actions_act_window_message", function(require) {
); );
return dialog.open()._opened; return dialog.open()._opened;
}, },
ir_actions_act_window_message_get_buttons: function(action, close_func) { ir_actions_act_window_message_get_buttons: function (action, close_func) {
// Return an array of button definitions from action // Return an array of button definitions from action
var self = this; var self = this;
return _.map(action.buttons || [], function(button_definition) { return _.map(action.buttons || [], function (button_definition) {
return { return {
text: button_definition.name || "No name set", text: button_definition.name || "No name set",
classes: button_definition.classes || "btn-default", classes: button_definition.classes || "btn-default",
click: function() { click: function () {
if (button_definition.type == "method") { if (button_definition.type === "method") {
self._rpc({ self._rpc({
model: button_definition.model, model: button_definition.model,
method: button_definition.method, method: button_definition.method,
args: button_definition.args, args: button_definition.args,
kwargs: button_definition.kwargs, kwargs: button_definition.kwargs,
}).then(function(result) { }).then(function (result) {
if (_.isObject(result)) { if (_.isObject(result)) {
self.do_action(result); self.do_action(result);
} }