summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/fields
diff options
context:
space:
mode:
authorPierre Masereel <pim@odoo.com>2017-04-14 13:30:04 +0200
committerPierre Masereel <pim@odoo.com>2017-04-18 13:14:50 +0200
commit2b22ceea6fd5f1e8e999235bcf5f3d3e15206710 (patch)
tree5f1a4466230989179114338050a47d0e700a0b34 /addons/web/static/src/js/fields
parenta055d5f2266e2a8490808474639814ccf8bc9c54 (diff)
[FIX] web: date_picker empty input field
When you try to empty a date or datetime field, you get a traceback saying that 'clone' and 'isSame' are not functions. This error occurs when you empty the field because the value is 'false' and you cannot call 'clone' or 'isSame' on false. To fix this, we ensure that value is not false before calling these methods on it. This bug has been introduced in rev: https://github.com/odoo/odoo/commit/c32724eae06c987e74a0600f1669696e499edc33
Diffstat (limited to 'addons/web/static/src/js/fields')
-rw-r--r--addons/web/static/src/js/fields/basic_fields.js5
1 files changed, 3 insertions, 2 deletions
diff --git a/addons/web/static/src/js/fields/basic_fields.js b/addons/web/static/src/js/fields/basic_fields.js
index 69fd7c5b791..d2649195111 100644
--- a/addons/web/static/src/js/fields/basic_fields.js
+++ b/addons/web/static/src/js/fields/basic_fields.js
@@ -268,7 +268,7 @@ var FieldDate = InputField.extend({
this.datewidget = this._makeDatePicker();
this.datewidget.on('datetime_changed', this, function () {
var value = this._getDateWidgetValue();
- if (!value.isSame(this.value)) {
+ if ((!value && this.value) || (value && !value.isSame(this.value))) {
this._setValue(value);
}
});
@@ -330,7 +330,8 @@ var FieldDateTime = FieldDate.extend({
* @private
*/
_getDateWidgetValue: function () {
- return this.datewidget.get_value().add(-this.getSession().tzOffset, 'minutes');
+ var value = this.datewidget.get_value();
+ return value && value.add(-this.getSession().tzOffset, 'minutes');
},
/**