From 12f6eeb450d2fa1e4e4722780d50ed3abdfd4bd1 Mon Sep 17 00:00:00 2001 From: Zakaria Makrelouf Date: Tue, 25 Apr 2017 13:15:01 +0100 Subject: [PATCH] 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 ----- .../__manifest__.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/__manifest__.py b/web_ir_actions_act_window_message/__manifest__.py index 7a553c52..9a8bdcc1 100644 --- a/web_ir_actions_act_window_message/__manifest__.py +++ b/web_ir_actions_act_window_message/__manifest__.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