From 34232639da11e94c5d3fdd70a69dd2f0eeb0aa13 Mon Sep 17 00:00:00 2001 From: Vincent Vinet Date: Mon, 23 Mar 2015 09:04:19 -0400 Subject: [PATCH 1/4] ADD web_datetime_options --- web_datetime_options/__init__.py | 0 web_datetime_options/__openerp__.py | 37 +++++++++++++++++++ .../static/src/js/datepicker.js | 35 ++++++++++++++++++ 3 files changed, 72 insertions(+) create mode 100644 web_datetime_options/__init__.py create mode 100644 web_datetime_options/__openerp__.py create mode 100644 web_datetime_options/static/src/js/datepicker.js diff --git a/web_datetime_options/__init__.py b/web_datetime_options/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/web_datetime_options/__openerp__.py b/web_datetime_options/__openerp__.py new file mode 100644 index 00000000..191247b9 --- /dev/null +++ b/web_datetime_options/__openerp__.py @@ -0,0 +1,37 @@ +# -*- coding: utf-8 -*- + +{ + "name": 'web_datetime_options', + "version": "0.1", + "description": """ +=========================================== +Allow passing options to datepicker widgets +=========================================== + +This will set all options specified in the "datepicker" option of datetime +fields to the datepicker. + +See http://api.jqueryui.com/datepicker/ for options + +Example: +-------- + + + +Contributors: +------------- + +- Vincent vinet + +""", + "depends": [ + 'base', + 'web', + ], + "js": [ + 'static/src/js/datepicker.js', + ], + "author": "Vincent Vinet", + "installable": True, + "active": False, +} diff --git a/web_datetime_options/static/src/js/datepicker.js b/web_datetime_options/static/src/js/datepicker.js new file mode 100644 index 00000000..cadfa513 --- /dev/null +++ b/web_datetime_options/static/src/js/datepicker.js @@ -0,0 +1,35 @@ +/*global openerp, _, $ */ + +openerp.web_datetime_options = function (instance) { + + "use strict"; + + instance.web.form.FieldDatetime = instance.web.form.FieldDatetime.extend({ + initialize_content: function() { + this._super(); + 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); + }); + } + } + } + }); + + instance.web.form.FieldDate = instance.web.form.FieldDate.extend({ + initialize_content: function() { + this._super(); + 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); + }); + } + } + } + }); +}; + From e2304df27486285dcf7840727f3a6426cfdc6fa1 Mon Sep 17 00:00:00 2001 From: Vincent Vinet Date: Mon, 23 Mar 2015 17:18:44 -0400 Subject: [PATCH 2/4] add copyright --- web_datetime_options/__init__.py | 21 ++++++++++++++++ web_datetime_options/__openerp__.py | 24 +++++++++++++++++-- .../static/src/js/datepicker.js | 18 ++++++++++++++ 3 files changed, 61 insertions(+), 2 deletions(-) diff --git a/web_datetime_options/__init__.py b/web_datetime_options/__init__.py index e69de29b..5daf7468 100644 --- a/web_datetime_options/__init__.py +++ b/web_datetime_options/__init__.py @@ -0,0 +1,21 @@ +# -*- 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 . +# +############################################################################## diff --git a/web_datetime_options/__openerp__.py b/web_datetime_options/__openerp__.py index 191247b9..c7ea3f35 100644 --- a/web_datetime_options/__openerp__.py +++ b/web_datetime_options/__openerp__.py @@ -1,4 +1,24 @@ -# -*- coding: utf-8 -*- +# -*- 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 . +# +############################################################################## { "name": 'web_datetime_options', @@ -21,7 +41,7 @@ Example: Contributors: ------------- -- Vincent vinet +- Vincent Vinet """, "depends": [ diff --git a/web_datetime_options/static/src/js/datepicker.js b/web_datetime_options/static/src/js/datepicker.js index cadfa513..6fade819 100644 --- a/web_datetime_options/static/src/js/datepicker.js +++ b/web_datetime_options/static/src/js/datepicker.js @@ -1,3 +1,21 @@ +/* + 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 . +*/ /*global openerp, _, $ */ openerp.web_datetime_options = function (instance) { From f37603c2ba236fc3a83866e5beb4fd6972f73e15 Mon Sep 17 00:00:00 2001 From: Vincent Vinet Date: Tue, 24 Mar 2015 07:46:59 -0400 Subject: [PATCH 3/4] rename web_datetime_options to web_widget_datepicker_options --- .../__init__.py | 0 .../__openerp__.py | 4 ++-- .../static/src/js/datepicker.js | 0 3 files changed, 2 insertions(+), 2 deletions(-) rename {web_datetime_options => web_widget_datepicker_options}/__init__.py (100%) rename {web_datetime_options => web_widget_datepicker_options}/__openerp__.py (96%) rename {web_datetime_options => web_widget_datepicker_options}/static/src/js/datepicker.js (100%) diff --git a/web_datetime_options/__init__.py b/web_widget_datepicker_options/__init__.py similarity index 100% rename from web_datetime_options/__init__.py rename to web_widget_datepicker_options/__init__.py diff --git a/web_datetime_options/__openerp__.py b/web_widget_datepicker_options/__openerp__.py similarity index 96% rename from web_datetime_options/__openerp__.py rename to web_widget_datepicker_options/__openerp__.py index c7ea3f35..7c406bb9 100644 --- a/web_datetime_options/__openerp__.py +++ b/web_widget_datepicker_options/__openerp__.py @@ -21,8 +21,8 @@ ############################################################################## { - "name": 'web_datetime_options', - "version": "0.1", + "name": 'web_widget_datepicker_options', + "version": "1.0", "description": """ =========================================== Allow passing options to datepicker widgets diff --git a/web_datetime_options/static/src/js/datepicker.js b/web_widget_datepicker_options/static/src/js/datepicker.js similarity index 100% rename from web_datetime_options/static/src/js/datepicker.js rename to web_widget_datepicker_options/static/src/js/datepicker.js From 9790a8ce1ca4ce898e85f2a9f2a4a1aadc2b28c4 Mon Sep 17 00:00:00 2001 From: Vincent Vinet Date: Tue, 24 Mar 2015 10:08:57 -0400 Subject: [PATCH 4/4] use include instead of extend --- web_widget_datepicker_options/static/src/js/datepicker.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/web_widget_datepicker_options/static/src/js/datepicker.js b/web_widget_datepicker_options/static/src/js/datepicker.js index 6fade819..304f119b 100644 --- a/web_widget_datepicker_options/static/src/js/datepicker.js +++ b/web_widget_datepicker_options/static/src/js/datepicker.js @@ -18,11 +18,11 @@ */ /*global openerp, _, $ */ -openerp.web_datetime_options = function (instance) { +openerp.web_widget_datepicker_options = function (instance) { "use strict"; - instance.web.form.FieldDatetime = instance.web.form.FieldDatetime.extend({ + instance.web.form.FieldDatetime.include({ initialize_content: function() { this._super(); var self = this; @@ -36,7 +36,7 @@ openerp.web_datetime_options = function (instance) { } }); - instance.web.form.FieldDate = instance.web.form.FieldDate.extend({ + instance.web.form.FieldDate.include({ initialize_content: function() { this._super(); var self = this;