From 3c0190d0a6c0d5ccc130fd9b685681fa9bac1de3 Mon Sep 17 00:00:00 2001 From: Christophe Matthieu Date: Thu, 23 Feb 2017 14:08:33 +0100 Subject: [IMP] web: use moment object instead of string for date Before this commit, the odoo web client used strings to represent dates. Now, the date is parsed into a moment object when the value is read from the server side. The widget formats the object to display the value. When the widget value changes, the value is parsed to a moment object. The value is automatically formatted to server value in ajax calls (toJSON method). --- addons/web/static/src/js/fields/basic_fields.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'addons/web/static/src/js/fields/basic_fields.js') diff --git a/addons/web/static/src/js/fields/basic_fields.js b/addons/web/static/src/js/fields/basic_fields.js index 2dedec8978d..fdbdee908e6 100644 --- a/addons/web/static/src/js/fields/basic_fields.js +++ b/addons/web/static/src/js/fields/basic_fields.js @@ -133,9 +133,8 @@ var FieldDate = InputField.extend({ if (this.mode === 'edit') { this.datewidget = this._makeDatePicker(); this.datewidget.on('datetime_changed', this, function () { - var value = this._parseValue(this.datewidget.get_value()); - if (value !== this._parseValue(this.value)) { - this._setValue(value); + if (!this.datewidget.get_value().isSame(this.value)) { + this._setValue(this.datewidget.get_value()); } }); def = this.datewidget.appendTo('
').done(function () { -- cgit v1.2.3