From 3578bfb6e118ddf6ea6624133d45bace383e62e0 Mon Sep 17 00:00:00 2001 From: Stephan Rozendaal Date: Mon, 31 Jul 2017 15:37:14 +0200 Subject: [PATCH 1/3] [FIX] widget does not set options on the widget The values of the date widget of the field are not being set. This is because the start function does not update the options, instead they are set in the init function. inherit the init function of the widget, and add the options here. --- web_widget_datepicker_options/static/src/js/datepicker.js | 4 +--- 1 file changed, 1 insertion(+), 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 6dc20939..c9b145ae 100644 --- a/web_widget_datepicker_options/static/src/js/datepicker.js +++ b/web_widget_datepicker_options/static/src/js/datepicker.js @@ -43,15 +43,13 @@ odoo.define('web_widget_datepicker_options', function (require) { }); DateWidget.include({ - start: function(parent, options) { + init: function(parent, options) { this._super.apply(this, arguments); var self = this; 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; }); } }, From b13a91ad0e7ba368018d243fd45902393fe79aca Mon Sep 17 00:00:00 2001 From: Stephan Rozendaal Date: Mon, 31 Jul 2017 15:39:37 +0200 Subject: [PATCH 2/3] [REM] Remove inheritance on DateTimeWidget The inheritance of the start function is not needed, because the function is already inherited from DateWidget. --- .../static/src/js/datepicker.js | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/web_widget_datepicker_options/static/src/js/datepicker.js b/web_widget_datepicker_options/static/src/js/datepicker.js index c9b145ae..1d9f422b 100644 --- a/web_widget_datepicker_options/static/src/js/datepicker.js +++ b/web_widget_datepicker_options/static/src/js/datepicker.js @@ -24,24 +24,8 @@ odoo.define('web_widget_datepicker_options', function (require) { 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.__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; - }); - } - }, - }); - DateWidget.include({ init: function(parent, options) { this._super.apply(this, arguments); From 6cb33c664b4248f796a575637bbc44673708261e Mon Sep 17 00:00:00 2001 From: Stephan Rozendaal Date: Tue, 1 Aug 2017 10:14:09 +0200 Subject: [PATCH 3/3] [FIX] Check if date widget properties exist the options property of the dateWidget does not exist when the field is rendered in for example a list view. Check if the options and datepicker properties exist first. --- .../static/src/js/datepicker.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/web_widget_datepicker_options/static/src/js/datepicker.js b/web_widget_datepicker_options/static/src/js/datepicker.js index 1d9f422b..89750b2a 100644 --- a/web_widget_datepicker_options/static/src/js/datepicker.js +++ b/web_widget_datepicker_options/static/src/js/datepicker.js @@ -30,11 +30,13 @@ odoo.define('web_widget_datepicker_options', function (require) { init: function(parent, options) { this._super.apply(this, arguments); var self = this; - if (this.__parentedParent.options.datepicker) { - var options = this.__parentedParent.options.datepicker; - $.each(options, function(value, key) { - self.options[value] = key; - }); + if (self.__parentedParent.options instanceof Object) { + if (self.__parentedParent.options.datepicker instanceof Object) { + var options = this.__parentedParent.options.datepicker; + $.each(options, function(value, key) { + self.options[value] = key; + }); + } } }, });