[FIX] web_widget_datepicker_options: Apply fixes after migration to v11

This applies some changes to the module after migration, to conform new
guidelines and conventions for version 11.0.

In addition, this applies the following fixes:
- The widged didn't work when the field was a `datetime` due to a typo
  in a JS conditional
- Replaced `Object.assign()` -> `_.assign()` to improve
  browser-compatibility
This commit is contained in:
Luis González
2018-05-28 01:52:27 +00:00
parent 9b264c286e
commit c704912955
6 changed files with 52 additions and 93 deletions

View File

@@ -1,20 +1,5 @@
/*
OpenERP, Open Source Management Solution
This module copyright (C) 2015 Savoir-faire Linux
(<http://www.savoirfairelinux.com>).
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 <http://www.gnu.org/licenses/>.
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
*/
odoo.define('web_widget_datepicker_options.datepicker', function(require) {
@@ -24,9 +9,12 @@ odoo.define('web_widget_datepicker_options.datepicker', function(require) {
Widget.DateWidget.include({
init: function() {
this._super.apply(this, arguments);
if(typeof this.__parentedParent !== 'undefined' && this.__parentedParent.field.type === 'date' && this.__parentedParent.nodeOptions){
var datepicker = this.__parentedParent.nodeOptions.datepicker;
Object.assign(this.options, datepicker);
var parent = this.getParent();
if(typeof parent !== 'undefined'
&& parent.field.type === 'date'
&& parent.nodeOptions){
var datepicker = parent.nodeOptions.datepicker;
_.assign(this.options, datepicker);
}
},
});
@@ -34,9 +22,12 @@ odoo.define('web_widget_datepicker_options.datepicker', function(require) {
Widget.DateTimeWidget.include({
init: function() {
this._super.apply(this, arguments);
if(typeof this.__parentedParent !== 'undefined' && this.__parentedParent.field.type === 'date' && this.__parentedParent.nodeOptions){
var datepicker = this.__parentedParent.nodeOptions.datepicker;
Object.assign(this.options, datepicker);
var parent = this.getParent();
if(typeof parent !== 'undefined'
&& parent.field.type === 'datetime'
&& parent.nodeOptions){
var datepicker = parent.nodeOptions.datepicker;
_.assign(this.options, datepicker);
}
},
});