Files
web/web_widget_datepicker_options/static/src/js/datepicker.js
Luis González ba73183d64 [FIX] web_widget_datepicker_options: Fix error when field is undefined
Currently, when a view is rendered and a date or datetime field is not
defined (e.g. when designing reports), it causes a JS error.

This patch fixes the above error.
2018-06-11 00:00:07 +00:00

37 lines
1.2 KiB
JavaScript

/*
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
*/
odoo.define('web_widget_datepicker_options.datepicker', function(require) {
"use strict";
var Widget = require('web.datepicker');
Widget.DateWidget.include({
init: function() {
this._super.apply(this, arguments);
var parent = this.getParent();
if(typeof parent !== 'undefined'
&& typeof parent.field !== 'undefined'
&& parent.field.type === 'date'
&& parent.nodeOptions){
var datepicker = parent.nodeOptions.datepicker;
_.assign(this.options, datepicker);
}
},
});
Widget.DateTimeWidget.include({
init: function() {
this._super.apply(this, arguments);
var parent = this.getParent();
if(typeof parent !== 'undefined'
&& typeof parent.field !== 'undefined'
&& parent.field.type === 'datetime'
&& parent.nodeOptions){
var datepicker = parent.nodeOptions.datepicker;
_.assign(this.options, datepicker);
}
},
});
});