From 4e3b640b053176849eab89b25e6070857782e676 Mon Sep 17 00:00:00 2001 From: Benjamin Willig Date: Tue, 23 May 2017 17:25:01 +0200 Subject: [PATCH] [MIG] web_ir_actions_act_window_message: Migration to 10. Also added HTML handling --- .../odoo/__init__.py | 1 + .../odoo/addons/__init__.py | 1 + .../addons/web_ir_actions_act_window_message | 1 + .../setup.py | 6 +++++ web_ir_actions_act_window_message/README.rst | 5 +++- .../__manifest__.py | 2 +- .../js/web_ir_actions_act_window_message.js | 26 ++++++++++++------- 7 files changed, 31 insertions(+), 11 deletions(-) create mode 100644 setup/web_ir_actions_act_window_message/odoo/__init__.py create mode 100644 setup/web_ir_actions_act_window_message/odoo/addons/__init__.py create mode 120000 setup/web_ir_actions_act_window_message/odoo/addons/web_ir_actions_act_window_message create mode 100644 setup/web_ir_actions_act_window_message/setup.py diff --git a/setup/web_ir_actions_act_window_message/odoo/__init__.py b/setup/web_ir_actions_act_window_message/odoo/__init__.py new file mode 100644 index 00000000..de40ea7c --- /dev/null +++ b/setup/web_ir_actions_act_window_message/odoo/__init__.py @@ -0,0 +1 @@ +__import__('pkg_resources').declare_namespace(__name__) diff --git a/setup/web_ir_actions_act_window_message/odoo/addons/__init__.py b/setup/web_ir_actions_act_window_message/odoo/addons/__init__.py new file mode 100644 index 00000000..de40ea7c --- /dev/null +++ b/setup/web_ir_actions_act_window_message/odoo/addons/__init__.py @@ -0,0 +1 @@ +__import__('pkg_resources').declare_namespace(__name__) diff --git a/setup/web_ir_actions_act_window_message/odoo/addons/web_ir_actions_act_window_message b/setup/web_ir_actions_act_window_message/odoo/addons/web_ir_actions_act_window_message new file mode 120000 index 00000000..9ba0c510 --- /dev/null +++ b/setup/web_ir_actions_act_window_message/odoo/addons/web_ir_actions_act_window_message @@ -0,0 +1 @@ +../../../../web_ir_actions_act_window_message \ No newline at end of file diff --git a/setup/web_ir_actions_act_window_message/setup.py b/setup/web_ir_actions_act_window_message/setup.py new file mode 100644 index 00000000..28c57bb6 --- /dev/null +++ b/setup/web_ir_actions_act_window_message/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +) diff --git a/web_ir_actions_act_window_message/README.rst b/web_ir_actions_act_window_message/README.rst index 4a64a92e..3772ad3e 100644 --- a/web_ir_actions_act_window_message/README.rst +++ b/web_ir_actions_act_window_message/README.rst @@ -19,6 +19,8 @@ Depend on this module and return # you can create your own close button with an action of type # ir.actions.act_window_close 'close_button_title': 'Make this window go away', + # Use HTML instead of text + 'is_html_message': True, # this is an optional list of buttons to show 'buttons': [ # a button can be any action (also ir.actions.report.xml et al) @@ -73,6 +75,7 @@ Contributors * Holger Brunn * Zakaria Makrelouf (ACSONE SA/NV) +* Benjamin Willig (ACSONE SA/NV) Maintainer ---------- @@ -85,4 +88,4 @@ This module is maintained by the OCA. OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use. -To contribute to this module, please visit http://odoo-community.org. +To contribute to this module, please visit http://odoo-community.org. \ No newline at end of file diff --git a/web_ir_actions_act_window_message/__manifest__.py b/web_ir_actions_act_window_message/__manifest__.py index 9a8bdcc1..5dd3b18b 100644 --- a/web_ir_actions_act_window_message/__manifest__.py +++ b/web_ir_actions_act_window_message/__manifest__.py @@ -3,7 +3,7 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). { "name": "Client side message boxes", - "version": "9.0.1.0.0", + "version": "10.0.1.0.0", "author": "Therp BV, " "ACSONE SA/NV, " "Odoo Community Association (OCA)", diff --git a/web_ir_actions_act_window_message/static/src/js/web_ir_actions_act_window_message.js b/web_ir_actions_act_window_message/static/src/js/web_ir_actions_act_window_message.js index 4ea153d4..1b0708d7 100644 --- a/web_ir_actions_act_window_message/static/src/js/web_ir_actions_act_window_message.js +++ b/web_ir_actions_act_window_message/static/src/js/web_ir_actions_act_window_message.js @@ -7,7 +7,6 @@ odoo.define('web.web_ir_actions_act_window_message', function(require) var ActionManager = require('web.ActionManager'), core = require('web.core'), - _ = require('_'), Model = require('web.Model'), Dialog = require('web.Dialog'); @@ -33,20 +32,29 @@ odoo.define('web.web_ir_actions_act_window_message', function(require) }) } + var is_html = action.is_html_message === true; + var content_properties = {}; + + if (is_html) { + content_properties = { + html: action.message, + }; + } else { + content_properties = { + text: action.message, + css: { + 'white-space': 'pre-line', + } + }; + } + var dialog = new Dialog( this, _.extend( { size: 'medium', title: action.title, - $content: $('
', - { - text: action.message, - css: { - 'white-space': 'pre-line', - } - } - ), + $content: $('
', content_properties), buttons: buttons.concat( this.ir_actions_act_window_message_get_buttons( action, function() { dialog.close() })