diff --git a/web_widget_datepicker_options/README.rst b/web_widget_datepicker_options/README.rst index f21fe3d5..1169ad97 100644 --- a/web_widget_datepicker_options/README.rst +++ b/web_widget_datepicker_options/README.rst @@ -1,6 +1,8 @@ .. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg - :alt: License: AGPL-3 + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 +========================= Datepicker Widget Options ========================= @@ -10,22 +12,25 @@ the datepicker widget. The option are passed as-is and are not validated. To see all supported options, see the `API documentation `_. - Usage ===== You must pass all options through the "datepicker" field in the options:: ... - + ... +.. 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/9.0 + + Known issues / Roadmap ====================== * Absolutely no validation on options. - Bug Tracker =========== @@ -34,10 +39,14 @@ In case of trouble, please check there if your issue has already been reported. If you spotted it first, help us smashing it by providing a detailed and welcomed feedback `here `_. - Credits ======= +Images +------ + +* Odoo Community Association: `Icon `_. + Contributors ------------ diff --git a/web_widget_datepicker_options/__init__.py b/web_widget_datepicker_options/__init__.py index 5daf7468..abdcd405 100644 --- a/web_widget_datepicker_options/__init__.py +++ b/web_widget_datepicker_options/__init__.py @@ -1,21 +1,3 @@ -# -*- encoding: utf-8 -*- -############################################################################## -# -# OpenERP, Open Source Management Solution -# This module copyright (C) 2015 Savoir-faire Linux -# (). -# -# 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 . -# -############################################################################## +# -*- coding: utf-8 -*- +# Copyright 2015 Savoir-faire Linux +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). diff --git a/web_widget_datepicker_options/__manifest__.py b/web_widget_datepicker_options/__manifest__.py index 67b23c1e..2d27257b 100644 --- a/web_widget_datepicker_options/__manifest__.py +++ b/web_widget_datepicker_options/__manifest__.py @@ -1,37 +1,20 @@ -# -*- encoding: utf-8 -*- -############################################################################## -# -# OpenERP, Open Source Management Solution -# This module copyright (C) 2015 Savoir-faire Linux -# (). -# -# 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 . -# -############################################################################## +# -*- coding: utf-8 -*- +# Copyright 2015 Savoir-faire Linux +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). { "name": 'web_widget_datepicker_options', - "version": "8.0.1.0.0", + "version": "9.0.1.0.0", "depends": [ 'base', 'web', ], "data": [ 'view/qweb.xml', + 'demo/web_widget_datepicker_options_demo.xml' ], "author": "Vincent Vinet, " "Odoo Community Association (OCA)", - 'installable': False, - "active": False, + "license": "AGPL-3", + 'installable': True, } diff --git a/web_widget_datepicker_options/demo/web_widget_datepicker_options_demo.xml b/web_widget_datepicker_options/demo/web_widget_datepicker_options_demo.xml new file mode 100644 index 00000000..a8568b61 --- /dev/null +++ b/web_widget_datepicker_options/demo/web_widget_datepicker_options_demo.xml @@ -0,0 +1,18 @@ + + + + + datepicker_options + res.users + + + +

Datepicker Demo

+
+
+
+
diff --git a/web_widget_datepicker_options/static/src/js/datepicker.js b/web_widget_datepicker_options/static/src/js/datepicker.js index 304f119b..6dc20939 100644 --- a/web_widget_datepicker_options/static/src/js/datepicker.js +++ b/web_widget_datepicker_options/static/src/js/datepicker.js @@ -18,36 +18,43 @@ */ /*global openerp, _, $ */ -openerp.web_widget_datepicker_options = function (instance) { +odoo.define('web_widget_datepicker_options', function (require) { "use strict"; - instance.web.form.FieldDatetime.include({ - initialize_content: function() { - this._super(); + var core = require('web.core'); + + var DateTimeWidget = require('web.datepicker').DateTimeWidget; + var DateWidget = require('web.datepicker').DateWidget; + + DateTimeWidget.include({ + start: function(parent, options) { + this._super.apply(this, arguments); var self = this; - if (this.datewidget) { - if (typeof this.options.datepicker === 'object') { - $.map(this.options.datepicker, function(value, key) { - self.datewidget.picker('option', key, value); - }); - } + if (this.__parentedParent.options.datepicker) { + var options = this.__parentedParent.options.datepicker; + $.each(options, function(value, key) { + self.options[value] = key; + self.picker[value] = key; + self.picker.options[value] = key; + }); } - } + }, }); - instance.web.form.FieldDate.include({ - initialize_content: function() { - this._super(); + DateWidget.include({ + start: function(parent, options) { + this._super.apply(this, arguments); var self = this; - if (this.datewidget) { - if (typeof this.options.datepicker === 'object') { - $.map(this.options.datepicker, function(value, key) { - self.datewidget.picker('option', key, value); - }); - } + if (this.__parentedParent.options.datepicker) { + var options = this.__parentedParent.options.datepicker; + $.each(options, function(value, key) { + self.options[value] = key; + self.picker[value] = key; + self.picker.options[value] = key; + }); } - } + }, }); -}; +}); diff --git a/web_widget_datepicker_options/view/qweb.xml b/web_widget_datepicker_options/view/qweb.xml index 9921348d..67c430d2 100644 --- a/web_widget_datepicker_options/view/qweb.xml +++ b/web_widget_datepicker_options/view/qweb.xml @@ -1,10 +1,8 @@ - - - - - + + +