forked from Techsystech/web
[MIG] web_ir_actions_act_window_message
parent
e288227937
commit
e776140f15
|
@ -0,0 +1 @@
|
||||||
|
../../../../web_ir_actions_act_window_message
|
|
@ -0,0 +1,6 @@
|
||||||
|
import setuptools
|
||||||
|
|
||||||
|
setuptools.setup(
|
||||||
|
setup_requires=['setuptools-odoo'],
|
||||||
|
odoo_addon=True,
|
||||||
|
)
|
|
@ -2,20 +2,12 @@
|
||||||
# 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": "12.0.1.0.0",
|
"version": "13.0.1.0.0",
|
||||||
"author": "Therp BV, "
|
"author": "Therp BV, " "ACSONE SA/NV, " "Odoo Community Association (OCA)",
|
||||||
"ACSONE SA/NV, "
|
|
||||||
"Odoo Community Association (OCA)",
|
|
||||||
"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": [
|
"depends": ["web"],
|
||||||
'web',
|
"data": ["views/templates.xml"],
|
||||||
],
|
"qweb": ["static/src/xml/web_ir_actions_act_window_message.xml"],
|
||||||
"data": [
|
|
||||||
'views/templates.xml',
|
|
||||||
],
|
|
||||||
"qweb": [
|
|
||||||
'static/src/xml/web_ir_actions_act_window_message.xml',
|
|
||||||
],
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,42 +1,38 @@
|
||||||
/* 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"),
|
||||||
core = require('web.core'),
|
core = require("web.core"),
|
||||||
Dialog = require('web.Dialog');
|
Dialog = require("web.Dialog");
|
||||||
|
|
||||||
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) {
|
||||||
controller.widget.reload();
|
controller.widget.reload();
|
||||||
}
|
}
|
||||||
dialog.close()
|
|
||||||
},
|
},
|
||||||
classes: 'btn-default',
|
classes: "btn-default",
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
var is_html = action.is_html_message === true;
|
var is_html = action.is_html_message === true;
|
||||||
|
@ -50,8 +46,8 @@ odoo.define('web.web_ir_actions_act_window_message', function(require)
|
||||||
content_properties = {
|
content_properties = {
|
||||||
text: action.message,
|
text: action.message,
|
||||||
css: {
|
css: {
|
||||||
'white-space': 'pre-line',
|
"white-space": "pre-line",
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,56 +55,54 @@ odoo.define('web.web_ir_actions_act_window_message', function(require)
|
||||||
this,
|
this,
|
||||||
_.extend(
|
_.extend(
|
||||||
{
|
{
|
||||||
size: 'medium',
|
size: "medium",
|
||||||
title: action.title,
|
title: action.title,
|
||||||
$content: $('<div>', content_properties),
|
$content: $("<div>", content_properties),
|
||||||
buttons: buttons.concat(
|
buttons: buttons.concat(
|
||||||
this.ir_actions_act_window_message_get_buttons(
|
this.ir_actions_act_window_message_get_buttons(
|
||||||
action, function() { dialog.close() })
|
action,
|
||||||
|
function() {
|
||||||
|
dialog.close();
|
||||||
|
}
|
||||||
|
)
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
options)
|
options
|
||||||
)
|
)
|
||||||
|
);
|
||||||
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);
|
||||||
}
|
}
|
||||||
// always refresh the view after the action
|
// Always refresh the view after the action
|
||||||
// ex: action updates a status
|
// ex: action updates a status
|
||||||
var controller = self.getCurrentController();
|
var controller = self.getCurrentController();
|
||||||
if (controller && controller.widget) {
|
if (controller && controller.widget) {
|
||||||
controller.widget.reload();
|
controller.widget.reload();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
self.do_action(button_definition);
|
self.do_action(button_definition);
|
||||||
}
|
}
|
||||||
close_func();
|
close_func();
|
||||||
},
|
},
|
||||||
}
|
};
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
<templates>
|
<templates>
|
||||||
<div t-name="web_ir_actions_act_window_message">
|
<div t-name="web_ir_actions_act_window_message">
|
||||||
<div><t t-esc="action.message" /></div>
|
<div>
|
||||||
|
<t t-esc="action.message" />
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</templates>
|
</templates>
|
||||||
|
|
|
@ -1,13 +1,17 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
<!-- 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>
|
<odoo>
|
||||||
|
<template
|
||||||
<template id="assets_backend" name="web_ir_actions_act_window_message assets" inherit_id="web.assets_backend">
|
id="assets_backend"
|
||||||
|
name="web_ir_actions_act_window_message assets"
|
||||||
|
inherit_id="web.assets_backend"
|
||||||
|
>
|
||||||
<xpath expr="." position="inside">
|
<xpath expr="." position="inside">
|
||||||
<script type="text/javascript" src="/web_ir_actions_act_window_message/static/src/js/web_ir_actions_act_window_message.js"></script>
|
<script
|
||||||
|
type="text/javascript"
|
||||||
|
src="/web_ir_actions_act_window_message/static/src/js/web_ir_actions_act_window_message.js"
|
||||||
|
/>
|
||||||
</xpath>
|
</xpath>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
</odoo>
|
</odoo>
|
||||||
|
|
Loading…
Reference in New Issue