From 01b05149400fa49c1c1d2a9d309f63756c1dbc79 Mon Sep 17 00:00:00 2001 From: Quentin Theuret Date: Sat, 17 Feb 2018 09:33:41 +0100 Subject: [PATCH] [MIG] Migrate web_dialog_size module to v11 --- web_dialog_size/README.rst | 3 +- web_dialog_size/__init__.py | 2 + web_dialog_size/__manifest__.py | 5 +- .../static/src/js/web_dialog_size.js | 46 ++++++++++--------- 4 files changed, 32 insertions(+), 24 deletions(-) diff --git a/web_dialog_size/README.rst b/web_dialog_size/README.rst index c936a028..6cc0acf8 100644 --- a/web_dialog_size/README.rst +++ b/web_dialog_size/README.rst @@ -19,7 +19,7 @@ parameter `web_dialog_size.default_maximize` to `1`. .. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas :alt: Try me on Runbot - :target: https://runbot.odoo-community.org/runbot/162/10.0 + :target: https://runbot.odoo-community.org/runbot/162/11.0 Bug Tracker =========== @@ -47,6 +47,7 @@ Contributors * Siddharth Bhalgami * Wolfgang Pichler * David Vidal +* Quentin Theuret Do not contact contributors directly about support or help with technical issues. diff --git a/web_dialog_size/__init__.py b/web_dialog_size/__init__.py index e69de29b..2b46a37e 100644 --- a/web_dialog_size/__init__.py +++ b/web_dialog_size/__init__.py @@ -0,0 +1,2 @@ +# Copyright 2018 Quentin Theuret +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). \ No newline at end of file diff --git a/web_dialog_size/__manifest__.py b/web_dialog_size/__manifest__.py index a609e7c3..df894502 100644 --- a/web_dialog_size/__manifest__.py +++ b/web_dialog_size/__manifest__.py @@ -1,5 +1,5 @@ -# -*- coding: utf-8 -*- # Copyright 2015 ACSONE SA/NV +# Copyright 2018 Amaris # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). { @@ -11,10 +11,11 @@ "Therp BV, " "Siddharth Bhalgami," "Tecnativa, " + "Amaris, " "Odoo Community Association (OCA)", 'website': "http://acsone.eu", 'category': 'web', - 'version': '10.0.1.0.2', + 'version': '11.0.1.0.1', 'license': 'AGPL-3', 'depends': [ 'web', diff --git a/web_dialog_size/static/src/js/web_dialog_size.js b/web_dialog_size/static/src/js/web_dialog_size.js index f6faa4b1..93056f72 100644 --- a/web_dialog_size/static/src/js/web_dialog_size.js +++ b/web_dialog_size/static/src/js/web_dialog_size.js @@ -1,34 +1,39 @@ odoo.define('web_dialog_size.web_dialog_size', function (require) { 'use strict'; -var Model = require('web.DataModel'); +var rpc = require('web.rpc'); var Dialog = require('web.Dialog'); Dialog.include({ - init: function (parent, options) { + willStart: function () { var self = this; - this._super.apply(this, arguments); - self.$modal.find('.dialog_button_extend').on('click', self.proxy('_extending')); - self.$modal.find('.dialog_button_restore').on('click', self.proxy('_restore')); - - new Model('ir.config_parameter').query(['key', 'value']). - filter([['key', '=', 'web_dialog_size.default_maximize']]).all().then(function(default_maximize) { - if (default_maximize.length && default_maximize[0].value == 1) { - self._extending(); - } else { - self._restore(); - } + return this._super.apply(this, arguments).then(function () { + self.$modal.find('.dialog_button_extend').on('click', self.proxy('_extending')); + self.$modal.find('.dialog_button_restore').on('click', self.proxy('_restore')); + return rpc.query({ + model: 'ir.config_parameter', + method: 'get_param', + args: ['web_dialog_size.default_maximize',], + }).then(function(default_maximize) { + if (default_maximize === "True" || default_maximize === 1) { + self._extending(); + } else { + self._restore(); + } + }); }); }, open: function() { - var res = this._super.apply(this, arguments); - this.$modal.draggable({ - handle: '.modal-header', - helper: false - }); - return res; + this._super.apply(this, arguments); + if (this.$modal) { + this.$modal.draggable({ + handle: '.modal-header', + helper: false + }); + }; + return this; }, close: function() { @@ -36,8 +41,7 @@ Dialog.include({ if (draggable) { this.$modal.draggable("destroy"); } - var res = this._super.apply(this, arguments); - return res; + return this._super.apply(this, arguments); }, _extending: function() {