From 115568212c0b62540471708937e8ec3f70049b5c Mon Sep 17 00:00:00 2001 From: Holger Brunn Date: Thu, 3 Mar 2016 17:27:19 +0100 Subject: [PATCH 1/9] allow to pass a list of buttons --- web_ir_actions_act_window_message/README.rst | 25 ++++++++- .../js/web_ir_actions_act_window_message.js | 55 ++++++++++++++++++- 2 files changed, 77 insertions(+), 3 deletions(-) diff --git a/web_ir_actions_act_window_message/README.rst b/web_ir_actions_act_window_message/README.rst index f330f0bf..8341746d 100644 --- a/web_ir_actions_act_window_message/README.rst +++ b/web_ir_actions_act_window_message/README.rst @@ -14,6 +14,30 @@ Depend on this module and return 'type': 'ir.actions.act_window.message', 'title': _('My title'), 'message': _('My message'), + # this is an optional list of buttons to show + 'buttons': [ + # a button can be any action (also ir.actions.report.xml et al) + { + 'type': 'ir.actions.act_window', + 'name': 'All customers', + 'res_model': 'res.partner', + 'view_mode': 'form', + 'views': [[False, 'list'], [False, 'form']], + 'domain': [('customer', '=', True)], + }, + # or if type == method, you need to pass a model, a method name and + # parameters + { + 'type': 'method', + 'name': _('Yes, do it'), + 'model': self._name, + 'method': 'myfunction', + # list of arguments to pass positionally + 'args': [self.ids], + # dictionary of keyword arguments + 'kwargs': {'force': True}, + } + ] } You are responsible for translating the messages. @@ -24,7 +48,6 @@ Known issues / Roadmap * add `message_type` to differenciate between warnings, errors, etc. * have one `message_type` to show a nonmodal warning on top right * have `button_title` to set the button title -* have `buttons` containing button names and action definitions for triggering actions from the message box Bug Tracker 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 bfc6f55d..95f3b26d 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 @@ -24,7 +24,8 @@ openerp.web_ir_actions_act_window_message = function(instance) instance.web.ActionManager.include({ ir_actions_act_window_message: function(action, options) { - var dialog = new instance.web.Dialog( + var self = this, + dialog = new instance.web.Dialog( this, { size: 'medium', @@ -35,7 +36,10 @@ openerp.web_ir_actions_act_window_message = function(instance) click: function() { dialog.close() }, oe_link_class: 'oe_highlight', }, - ], + ].concat( + this.ir_actions_act_window_message_get_buttons( + action, function() { dialog.close() }) + ), }, jQuery(instance.web.qweb.render( 'web_ir_actions_act_window_message', @@ -46,5 +50,52 @@ openerp.web_ir_actions_act_window_message = function(instance) ) return dialog.open(); }, + ir_actions_act_window_message_get_buttons: function(action, close_func) + { + // return an array of button definitions from action + var self = this; + return _.map(action.buttons || [], function(button_definition) + { + return { + text: button_definition.name || 'No name set', + oe_link_class: button_definition.oe_link_class || + 'oe_highlight', + click: function() { + if(button_definition.type == 'method') + { + (new instance.web.Model(button_definition.model)) + .call( + button_definition.method, + button_definition.args, + button_definition.kwargs + ).then(function(result) + { + if(_.isObject(result)) + { + self.do_action(result); + } + else + { + if( + self.inner_widget && + self.inner_widget.views + ) + { + self.inner_widget + .views[self.inner_widget.active_view] + .controller.recursive_reload(); + } + } + }); + } + else + { + self.do_action(button_definition); + } + close_func(); + }, + } + }); + }, }); } From 4679318ae6596f3e5c5fccc02e57140d2aaad769 Mon Sep 17 00:00:00 2001 From: Holger Brunn Date: Thu, 3 Mar 2016 17:38:57 +0100 Subject: [PATCH 2/9] implement close_button_title --- web_ir_actions_act_window_message/README.rst | 6 ++++- .../js/web_ir_actions_act_window_message.js | 22 ++++++++++++------- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/web_ir_actions_act_window_message/README.rst b/web_ir_actions_act_window_message/README.rst index 8341746d..cc368bed 100644 --- a/web_ir_actions_act_window_message/README.rst +++ b/web_ir_actions_act_window_message/README.rst @@ -14,6 +14,11 @@ Depend on this module and return 'type': 'ir.actions.act_window.message', 'title': _('My title'), 'message': _('My message'), + # optional title of the close button, if not set, will be _('Close') + # if set False, no close button will be shown + # 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', # this is an optional list of buttons to show 'buttons': [ # a button can be any action (also ir.actions.report.xml et al) @@ -47,7 +52,6 @@ Known issues / Roadmap * add `message_type` to differenciate between warnings, errors, etc. * have one `message_type` to show a nonmodal warning on top right -* have `button_title` to set the button title Bug Tracker 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 95f3b26d..227cd671 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 @@ -25,18 +25,24 @@ openerp.web_ir_actions_act_window_message = function(instance) ir_actions_act_window_message: function(action, options) { var self = this, - dialog = new instance.web.Dialog( + buttons = []; + + if(action.close_button_title !== false) + { + buttons.push({ + text: action.close_button_title || + instance.web._t('Close'), + click: function() { dialog.close() }, + oe_link_class: 'oe_highlight', + }) + } + + var dialog = new instance.web.Dialog( this, { size: 'medium', title: action.title, - buttons: [ - { - text: instance.web._t('Close'), - click: function() { dialog.close() }, - oe_link_class: 'oe_highlight', - }, - ].concat( + buttons: buttons.concat( this.ir_actions_act_window_message_get_buttons( action, function() { dialog.close() }) ), From 436c6ad993bb076d229e6c2cd0e04704d6b65bf0 Mon Sep 17 00:00:00 2001 From: OCA Transbot Date: Mon, 23 Nov 2015 23:43:23 -0500 Subject: [PATCH 3/9] OCA Transbot updated translations from Transifex --- web_ir_actions_act_window_message/i18n/ar.po | 25 ++++++++++++++++++ web_ir_actions_act_window_message/i18n/de.po | 26 +++++++++++++++++++ web_ir_actions_act_window_message/i18n/es.po | 26 +++++++++++++++++++ web_ir_actions_act_window_message/i18n/eu.po | 25 ++++++++++++++++++ web_ir_actions_act_window_message/i18n/fi.po | 25 ++++++++++++++++++ web_ir_actions_act_window_message/i18n/fr.po | 25 ++++++++++++++++++ web_ir_actions_act_window_message/i18n/hr.po | 25 ++++++++++++++++++ web_ir_actions_act_window_message/i18n/it.po | 25 ++++++++++++++++++ web_ir_actions_act_window_message/i18n/nl.po | 25 ++++++++++++++++++ .../i18n/pt_BR.po | 25 ++++++++++++++++++ web_ir_actions_act_window_message/i18n/sl.po | 25 ++++++++++++++++++ web_ir_actions_act_window_message/i18n/tr.po | 25 ++++++++++++++++++ 12 files changed, 302 insertions(+) create mode 100644 web_ir_actions_act_window_message/i18n/ar.po create mode 100644 web_ir_actions_act_window_message/i18n/de.po create mode 100644 web_ir_actions_act_window_message/i18n/es.po create mode 100644 web_ir_actions_act_window_message/i18n/eu.po create mode 100644 web_ir_actions_act_window_message/i18n/fi.po create mode 100644 web_ir_actions_act_window_message/i18n/fr.po create mode 100644 web_ir_actions_act_window_message/i18n/hr.po create mode 100644 web_ir_actions_act_window_message/i18n/it.po create mode 100644 web_ir_actions_act_window_message/i18n/nl.po create mode 100644 web_ir_actions_act_window_message/i18n/pt_BR.po create mode 100644 web_ir_actions_act_window_message/i18n/sl.po create mode 100644 web_ir_actions_act_window_message/i18n/tr.po diff --git a/web_ir_actions_act_window_message/i18n/ar.po b/web_ir_actions_act_window_message/i18n/ar.po new file mode 100644 index 00000000..c2bc8c41 --- /dev/null +++ b/web_ir_actions_act_window_message/i18n/ar.po @@ -0,0 +1,25 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * web_ir_actions_act_window_message +# +# Translators: +msgid "" +msgstr "" +"Project-Id-Version: web (8.0)\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2015-12-16 07:41+0000\n" +"PO-Revision-Date: 2015-11-07 11:20+0000\n" +"Last-Translator: <>\n" +"Language-Team: Arabic (http://www.transifex.com/oca/OCA-web-8-0/language/ar/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Language: ar\n" +"Plural-Forms: nplurals=6; plural=n==0 ? 0 : n==1 ? 1 : n==2 ? 2 : n%100>=3 && n%100<=10 ? 3 : n%100>=11 && n%100<=99 ? 4 : 5;\n" + +#. module: web_ir_actions_act_window_message +#. openerp-web +#: code:addons/web_ir_actions_act_window_message/static/src/js/web_ir_actions_act_window_message.js:34 +#, python-format +msgid "Close" +msgstr "إغلاق" diff --git a/web_ir_actions_act_window_message/i18n/de.po b/web_ir_actions_act_window_message/i18n/de.po new file mode 100644 index 00000000..1a53b664 --- /dev/null +++ b/web_ir_actions_act_window_message/i18n/de.po @@ -0,0 +1,26 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * web_ir_actions_act_window_message +# +# Translators: +# Rudolf Schnapka , 2016 +msgid "" +msgstr "" +"Project-Id-Version: web (8.0)\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2016-01-10 07:31+0000\n" +"PO-Revision-Date: 2016-01-18 20:15+0000\n" +"Last-Translator: Rudolf Schnapka \n" +"Language-Team: German (http://www.transifex.com/oca/OCA-web-8-0/language/de/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Language: de\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#. module: web_ir_actions_act_window_message +#. openerp-web +#: code:addons/web_ir_actions_act_window_message/static/src/js/web_ir_actions_act_window_message.js:34 +#, python-format +msgid "Close" +msgstr "Schließen" diff --git a/web_ir_actions_act_window_message/i18n/es.po b/web_ir_actions_act_window_message/i18n/es.po new file mode 100644 index 00000000..3b8d60e1 --- /dev/null +++ b/web_ir_actions_act_window_message/i18n/es.po @@ -0,0 +1,26 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * web_ir_actions_act_window_message +# +# Translators: +# Antonio Trueba, 2016 +msgid "" +msgstr "" +"Project-Id-Version: web (8.0)\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2016-01-10 07:31+0000\n" +"PO-Revision-Date: 2016-02-10 16:40+0000\n" +"Last-Translator: Antonio Trueba\n" +"Language-Team: Spanish (http://www.transifex.com/oca/OCA-web-8-0/language/es/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Language: es\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#. module: web_ir_actions_act_window_message +#. openerp-web +#: code:addons/web_ir_actions_act_window_message/static/src/js/web_ir_actions_act_window_message.js:34 +#, python-format +msgid "Close" +msgstr "Cerrar" diff --git a/web_ir_actions_act_window_message/i18n/eu.po b/web_ir_actions_act_window_message/i18n/eu.po new file mode 100644 index 00000000..5ff5a28f --- /dev/null +++ b/web_ir_actions_act_window_message/i18n/eu.po @@ -0,0 +1,25 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * web_ir_actions_act_window_message +# +# Translators: +msgid "" +msgstr "" +"Project-Id-Version: web (8.0)\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-02-18 09:01+0000\n" +"PO-Revision-Date: 2015-11-07 11:20+0000\n" +"Last-Translator: <>\n" +"Language-Team: Basque (http://www.transifex.com/oca/OCA-web-8-0/language/eu/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Language: eu\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#. module: web_ir_actions_act_window_message +#. openerp-web +#: code:addons/web_ir_actions_act_window_message/static/src/js/web_ir_actions_act_window_message.js:34 +#, python-format +msgid "Close" +msgstr "Itxi" diff --git a/web_ir_actions_act_window_message/i18n/fi.po b/web_ir_actions_act_window_message/i18n/fi.po new file mode 100644 index 00000000..30cc25fc --- /dev/null +++ b/web_ir_actions_act_window_message/i18n/fi.po @@ -0,0 +1,25 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * web_ir_actions_act_window_message +# +# Translators: +msgid "" +msgstr "" +"Project-Id-Version: web (8.0)\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2016-01-10 07:31+0000\n" +"PO-Revision-Date: 2015-11-07 11:20+0000\n" +"Last-Translator: <>\n" +"Language-Team: Finnish (http://www.transifex.com/oca/OCA-web-8-0/language/fi/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Language: fi\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#. module: web_ir_actions_act_window_message +#. openerp-web +#: code:addons/web_ir_actions_act_window_message/static/src/js/web_ir_actions_act_window_message.js:34 +#, python-format +msgid "Close" +msgstr "Sulje" diff --git a/web_ir_actions_act_window_message/i18n/fr.po b/web_ir_actions_act_window_message/i18n/fr.po new file mode 100644 index 00000000..92af8cf4 --- /dev/null +++ b/web_ir_actions_act_window_message/i18n/fr.po @@ -0,0 +1,25 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * web_ir_actions_act_window_message +# +# Translators: +msgid "" +msgstr "" +"Project-Id-Version: web (8.0)\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2015-11-23 13:46+0000\n" +"PO-Revision-Date: 2015-11-07 11:20+0000\n" +"Last-Translator: <>\n" +"Language-Team: French (http://www.transifex.com/oca/OCA-web-8-0/language/fr/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Language: fr\n" +"Plural-Forms: nplurals=2; plural=(n > 1);\n" + +#. module: web_ir_actions_act_window_message +#. openerp-web +#: code:addons/web_ir_actions_act_window_message/static/src/js/web_ir_actions_act_window_message.js:34 +#, python-format +msgid "Close" +msgstr "Fermer" diff --git a/web_ir_actions_act_window_message/i18n/hr.po b/web_ir_actions_act_window_message/i18n/hr.po new file mode 100644 index 00000000..6fdf3b7e --- /dev/null +++ b/web_ir_actions_act_window_message/i18n/hr.po @@ -0,0 +1,25 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * web_ir_actions_act_window_message +# +# Translators: +msgid "" +msgstr "" +"Project-Id-Version: web (8.0)\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2016-06-24 00:46+0000\n" +"PO-Revision-Date: 2015-11-07 11:20+0000\n" +"Last-Translator: <>\n" +"Language-Team: Croatian (http://www.transifex.com/oca/OCA-web-8-0/language/hr/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Language: hr\n" +"Plural-Forms: nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2;\n" + +#. module: web_ir_actions_act_window_message +#. openerp-web +#: code:addons/web_ir_actions_act_window_message/static/src/js/web_ir_actions_act_window_message.js:34 +#, python-format +msgid "Close" +msgstr "Zatvori" diff --git a/web_ir_actions_act_window_message/i18n/it.po b/web_ir_actions_act_window_message/i18n/it.po new file mode 100644 index 00000000..108201e8 --- /dev/null +++ b/web_ir_actions_act_window_message/i18n/it.po @@ -0,0 +1,25 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * web_ir_actions_act_window_message +# +# Translators: +msgid "" +msgstr "" +"Project-Id-Version: web (8.0)\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2016-03-17 07:29+0000\n" +"PO-Revision-Date: 2015-11-07 11:20+0000\n" +"Last-Translator: <>\n" +"Language-Team: Italian (http://www.transifex.com/oca/OCA-web-8-0/language/it/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Language: it\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#. module: web_ir_actions_act_window_message +#. openerp-web +#: code:addons/web_ir_actions_act_window_message/static/src/js/web_ir_actions_act_window_message.js:34 +#, python-format +msgid "Close" +msgstr "Chiudi" diff --git a/web_ir_actions_act_window_message/i18n/nl.po b/web_ir_actions_act_window_message/i18n/nl.po new file mode 100644 index 00000000..67049ccf --- /dev/null +++ b/web_ir_actions_act_window_message/i18n/nl.po @@ -0,0 +1,25 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * web_ir_actions_act_window_message +# +# Translators: +msgid "" +msgstr "" +"Project-Id-Version: web (8.0)\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-01-21 08:52+0000\n" +"PO-Revision-Date: 2015-11-07 11:20+0000\n" +"Last-Translator: <>\n" +"Language-Team: Dutch (http://www.transifex.com/oca/OCA-web-8-0/language/nl/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Language: nl\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#. module: web_ir_actions_act_window_message +#. openerp-web +#: code:addons/web_ir_actions_act_window_message/static/src/js/web_ir_actions_act_window_message.js:34 +#, python-format +msgid "Close" +msgstr "Sluiten" diff --git a/web_ir_actions_act_window_message/i18n/pt_BR.po b/web_ir_actions_act_window_message/i18n/pt_BR.po new file mode 100644 index 00000000..dd6d8167 --- /dev/null +++ b/web_ir_actions_act_window_message/i18n/pt_BR.po @@ -0,0 +1,25 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * web_ir_actions_act_window_message +# +# Translators: +msgid "" +msgstr "" +"Project-Id-Version: web (8.0)\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2016-03-11 02:17+0000\n" +"PO-Revision-Date: 2016-03-05 16:20+0000\n" +"Last-Translator: danimaribeiro \n" +"Language-Team: Portuguese (Brazil) (http://www.transifex.com/oca/OCA-web-8-0/language/pt_BR/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Language: pt_BR\n" +"Plural-Forms: nplurals=2; plural=(n > 1);\n" + +#. module: web_ir_actions_act_window_message +#. openerp-web +#: code:addons/web_ir_actions_act_window_message/static/src/js/web_ir_actions_act_window_message.js:34 +#, python-format +msgid "Close" +msgstr "Fechar" diff --git a/web_ir_actions_act_window_message/i18n/sl.po b/web_ir_actions_act_window_message/i18n/sl.po new file mode 100644 index 00000000..63ddbc00 --- /dev/null +++ b/web_ir_actions_act_window_message/i18n/sl.po @@ -0,0 +1,25 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * web_ir_actions_act_window_message +# +# Translators: +msgid "" +msgstr "" +"Project-Id-Version: web (8.0)\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2015-11-23 13:46+0000\n" +"PO-Revision-Date: 2015-11-08 05:45+0000\n" +"Last-Translator: Matjaž Mozetič \n" +"Language-Team: Slovenian (http://www.transifex.com/oca/OCA-web-8-0/language/sl/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Language: sl\n" +"Plural-Forms: nplurals=4; plural=(n%100==1 ? 0 : n%100==2 ? 1 : n%100==3 || n%100==4 ? 2 : 3);\n" + +#. module: web_ir_actions_act_window_message +#. openerp-web +#: code:addons/web_ir_actions_act_window_message/static/src/js/web_ir_actions_act_window_message.js:34 +#, python-format +msgid "Close" +msgstr "Zaključi" diff --git a/web_ir_actions_act_window_message/i18n/tr.po b/web_ir_actions_act_window_message/i18n/tr.po new file mode 100644 index 00000000..7d4493a4 --- /dev/null +++ b/web_ir_actions_act_window_message/i18n/tr.po @@ -0,0 +1,25 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * web_ir_actions_act_window_message +# +# Translators: +msgid "" +msgstr "" +"Project-Id-Version: web (8.0)\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2016-01-08 21:34+0000\n" +"PO-Revision-Date: 2015-12-30 22:16+0000\n" +"Last-Translator: Ahmet Altınışık \n" +"Language-Team: Turkish (http://www.transifex.com/oca/OCA-web-8-0/language/tr/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Language: tr\n" +"Plural-Forms: nplurals=2; plural=(n > 1);\n" + +#. module: web_ir_actions_act_window_message +#. openerp-web +#: code:addons/web_ir_actions_act_window_message/static/src/js/web_ir_actions_act_window_message.js:34 +#, python-format +msgid "Close" +msgstr "Kapat" From e88cc8b2ef080fbd9e1bac45a4acfbbcf09db432 Mon Sep 17 00:00:00 2001 From: Zakaria Makrelouf Date: Tue, 25 Apr 2017 13:15:01 +0100 Subject: [PATCH 4/9] [9.0][MIG]web_ir_actions_act_window_message: Migration to V9 * Update the module version to 9.0. * Align file header to the OCA Guidelines. * Migrate Javascript file to the V9 API. * Refresh the view before closing the dialog when clicking on close button --- web_ir_actions_act_window_message/README.rst | 1 + web_ir_actions_act_window_message/__init__.py | 20 ----- .../__openerp__.py | 30 +------ .../js/web_ir_actions_act_window_message.js | 82 ++++++++----------- .../views/templates.xml | 23 +++--- 5 files changed, 54 insertions(+), 102 deletions(-) diff --git a/web_ir_actions_act_window_message/README.rst b/web_ir_actions_act_window_message/README.rst index cc368bed..e991265c 100644 --- a/web_ir_actions_act_window_message/README.rst +++ b/web_ir_actions_act_window_message/README.rst @@ -70,6 +70,7 @@ Contributors ------------ * Holger Brunn +* Zakaria Makrelouf (ACSONE SA/NV) Maintainer ---------- diff --git a/web_ir_actions_act_window_message/__init__.py b/web_ir_actions_act_window_message/__init__.py index faef9dac..e69de29b 100644 --- a/web_ir_actions_act_window_message/__init__.py +++ b/web_ir_actions_act_window_message/__init__.py @@ -1,20 +0,0 @@ -# -*- coding: utf-8 -*- -############################################################################## -# -# OpenERP, Open Source Management Solution -# This module copyright (C) 2015 Therp BV . -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . -# -############################################################################## diff --git a/web_ir_actions_act_window_message/__openerp__.py b/web_ir_actions_act_window_message/__openerp__.py index 7a553c52..9a8bdcc1 100644 --- a/web_ir_actions_act_window_message/__openerp__.py +++ b/web_ir_actions_act_window_message/__openerp__.py @@ -1,27 +1,11 @@ # -*- coding: utf-8 -*- -############################################################################## -# -# OpenERP, Open Source Management Solution -# This module copyright (C) 2015 Therp BV . -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . -# -############################################################################## +# Copyright 2017 Therp BV, ACSONE SA/NV +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). { "name": "Client side message boxes", - "version": "8.0.1.0.0", + "version": "9.0.1.0.0", "author": "Therp BV, " + "ACSONE SA/NV, " "Odoo Community Association (OCA)", "license": "AGPL-3", "category": "Hidden/Dependency", @@ -35,10 +19,4 @@ "qweb": [ 'static/src/xml/web_ir_actions_act_window_message.xml', ], - "auto_install": False, - 'installable': False, - "application": False, - "external_dependencies": { - 'python': [], - }, } 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 227cd671..006ac8df 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 @@ -1,59 +1,51 @@ -//-*- coding: utf-8 -*- -//############################################################################ -// -// OpenERP, Open Source Management Solution -// This module copyright (C) 2015 Therp BV . -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . -// -//############################################################################ +/* Copyright 2017 Therp BV, ACSONE SA/NV + * * License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). */ + +odoo.define('web.web_ir_actions_act_window_message', function (require) { + "use strict"; + + var ActionManager = require('web.ActionManager'), + core = require('web.core'), + _ = require('_'), + Model = require('web.Model'), + Dialog = require('web.Dialog'); + + var _t = core._t; + + ActionManager.include({ + ir_actions_act_window_message: function(action, options){ -openerp.web_ir_actions_act_window_message = function(instance) -{ - instance.web.ActionManager.include({ - ir_actions_act_window_message: function(action, options) - { var self = this, buttons = []; if(action.close_button_title !== false) { buttons.push({ - text: action.close_button_title || - instance.web._t('Close'), - click: function() { dialog.close() }, + text: action.close_button_title || _t('Close'), + click: function() { + // refresh the view before closing the dialog + self.inner_widget.active_view + .controller.recursive_reload(); + dialog.close() + }, oe_link_class: 'oe_highlight', }) } - var dialog = new instance.web.Dialog( + var dialog = new Dialog( this, - { + _.extend({ size: 'medium', title: action.title, + $content: $('
', { + text: action.message, + }), buttons: buttons.concat( this.ir_actions_act_window_message_get_buttons( action, function() { dialog.close() }) ), - }, - jQuery(instance.web.qweb.render( - 'web_ir_actions_act_window_message', - { - 'this': this, - 'action': action, - })) - ) + }, options) + ); return dialog.open(); }, ir_actions_act_window_message_get_buttons: function(action, close_func) @@ -67,9 +59,8 @@ openerp.web_ir_actions_act_window_message = function(instance) oe_link_class: button_definition.oe_link_class || 'oe_highlight', click: function() { - if(button_definition.type == 'method') - { - (new instance.web.Model(button_definition.model)) + if(button_definition.type == 'method'){ + (new Model(button_definition.model)) .call( button_definition.method, button_definition.args, @@ -94,14 +85,13 @@ openerp.web_ir_actions_act_window_message = function(instance) } }); } - else - { + else{ self.do_action(button_definition); } close_func(); - }, + } } }); - }, + } }); -} +}); diff --git a/web_ir_actions_act_window_message/views/templates.xml b/web_ir_actions_act_window_message/views/templates.xml index 9ba42b0b..44b1c287 100644 --- a/web_ir_actions_act_window_message/views/templates.xml +++ b/web_ir_actions_act_window_message/views/templates.xml @@ -1,10 +1,13 @@ - - - - - - + + + + + + + + \ No newline at end of file From 41188649ba811020d0ead51a646e210db203d567 Mon Sep 17 00:00:00 2001 From: Zakaria Makrelouf Date: Thu, 4 May 2017 07:47:00 +0100 Subject: [PATCH 5/9] [MIG]web_ir_actions_act_window_message: make module installable. --- .../odoo_addons/__init__.py | 1 + .../odoo_addons/web_ir_actions_act_window_message | 1 + setup/web_ir_actions_act_window_message/setup.py | 6 ++++++ 3 files changed, 8 insertions(+) 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_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..6aee9885 --- /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, +) From 0d97ef6fdb5e66fc7bffa803eed8d1d52962c57b Mon Sep 17 00:00:00 2001 From: Zakaria Makrelouf Date: Sun, 7 May 2017 10:16:19 +0100 Subject: [PATCH 6/9] [REF]web_ir_actions_act_window_message: always refresh view after action --- .../src/js/web_ir_actions_act_window_message.js | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) 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 006ac8df..6a71ace1 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 @@ -71,18 +71,10 @@ odoo.define('web.web_ir_actions_act_window_message', function (require) { { self.do_action(result); } - else - { - if( - self.inner_widget && - self.inner_widget.views - ) - { - self.inner_widget - .views[self.inner_widget.active_view] - .controller.recursive_reload(); - } - } + // always refresh the view after the action + // ex: action updates a status + self.inner_widget.active_view + .controller.recursive_reload(); }); } else{ From a53490d5f85342f1347204ac588ddbac9c44b819 Mon Sep 17 00:00:00 2001 From: Zakaria Makrelouf Date: Tue, 16 May 2017 08:56:39 +0100 Subject: [PATCH 7/9] [REF] Reformat the code to have coherent coding style --- .../js/web_ir_actions_act_window_message.js | 45 +++++++++++-------- 1 file changed, 26 insertions(+), 19 deletions(-) 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 6a71ace1..fbc620a0 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 @@ -1,7 +1,8 @@ /* Copyright 2017 Therp BV, ACSONE SA/NV * * 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"; var ActionManager = require('web.ActionManager'), @@ -13,8 +14,8 @@ odoo.define('web.web_ir_actions_act_window_message', function (require) { var _t = core._t; ActionManager.include({ - ir_actions_act_window_message: function(action, options){ - + ir_actions_act_window_message: function(action, options) + { var self = this, buttons = []; @@ -34,18 +35,22 @@ odoo.define('web.web_ir_actions_act_window_message', function (require) { var dialog = new Dialog( this, - _.extend({ - size: 'medium', - title: action.title, - $content: $('
', { - text: action.message, - }), - buttons: buttons.concat( - this.ir_actions_act_window_message_get_buttons( - action, function() { dialog.close() }) - ), - }, options) - ); + _.extend( + { + size: 'medium', + title: action.title, + $content: $('
', + { + text: action.message, + } + ), + buttons: buttons.concat( + this.ir_actions_act_window_message_get_buttons( + action, function() { dialog.close() }) + ), + }, + options) + ) return dialog.open(); }, ir_actions_act_window_message_get_buttons: function(action, close_func) @@ -59,7 +64,8 @@ odoo.define('web.web_ir_actions_act_window_message', function (require) { oe_link_class: button_definition.oe_link_class || 'oe_highlight', click: function() { - if(button_definition.type == 'method'){ + if(button_definition.type == 'method') + { (new Model(button_definition.model)) .call( button_definition.method, @@ -77,13 +83,14 @@ odoo.define('web.web_ir_actions_act_window_message', function (require) { .controller.recursive_reload(); }); } - else{ + else + { self.do_action(button_definition); } close_func(); - } + }, } }); - } + }, }); }); From 311e60d82f6ec72a1d9dbd37c97dce867b4e2a4d Mon Sep 17 00:00:00 2001 From: Zakaria Makrelouf Date: Tue, 16 May 2017 09:00:16 +0100 Subject: [PATCH 8/9] [MIG] s/oe_link_class/classes s/oe_highlight/btn-default and add it to readme * In v9.0 odoo uses classes for dialog buttons instead of oe_link_class --- web_ir_actions_act_window_message/README.rst | 2 ++ .../static/src/js/web_ir_actions_act_window_message.js | 5 ++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/web_ir_actions_act_window_message/README.rst b/web_ir_actions_act_window_message/README.rst index e991265c..4a64a92e 100644 --- a/web_ir_actions_act_window_message/README.rst +++ b/web_ir_actions_act_window_message/README.rst @@ -41,6 +41,8 @@ Depend on this module and return 'args': [self.ids], # dictionary of keyword arguments 'kwargs': {'force': True}, + # button style + 'classes': 'btn-primary', } ] } 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 fbc620a0..d2a838e2 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 @@ -29,7 +29,7 @@ odoo.define('web.web_ir_actions_act_window_message', function(require) .controller.recursive_reload(); dialog.close() }, - oe_link_class: 'oe_highlight', + classes: 'btn-default', }) } @@ -61,8 +61,7 @@ odoo.define('web.web_ir_actions_act_window_message', function(require) { return { text: button_definition.name || 'No name set', - oe_link_class: button_definition.oe_link_class || - 'oe_highlight', + classes: button_definition.classes || 'btn-default', click: function() { if(button_definition.type == 'method') { From 58fc2a53ca20b343607b26b36f54b3e3638f7a74 Mon Sep 17 00:00:00 2001 From: Zakaria Makrelouf Date: Tue, 16 May 2017 09:37:43 +0100 Subject: [PATCH 9/9] [REF] wrap line breaks of the action message --- .../static/src/js/web_ir_actions_act_window_message.js | 3 +++ 1 file changed, 3 insertions(+) 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 d2a838e2..4ea153d4 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 @@ -42,6 +42,9 @@ odoo.define('web.web_ir_actions_act_window_message', function(require) $content: $('
', { text: action.message, + css: { + 'white-space': 'pre-line', + } } ), buttons: buttons.concat(