diff options
| author | Christophe Matthieu <chm@odoo.com> | 2017-02-28 08:47:05 +0100 |
|---|---|---|
| committer | Aaron Bohy <aab@odoo.com> | 2017-04-11 19:44:38 +0200 |
| commit | 7465798ccda4ff28c04283d295aae3fc49f2a46a (patch) | |
| tree | adc0e8a7155e2482317fc8151af61f4d0fc4c035 /addons/web/static/src/js/fields/field_utils.js | |
| parent | b34279c89a8d1247f74a710be69691a201841604 (diff) | |
[FIX] web: field_utils date
* list view must use stringtify value for py eval comparaison
* use utc to parse database value (avoid timezone error)
Diffstat (limited to 'addons/web/static/src/js/fields/field_utils.js')
| -rw-r--r-- | addons/web/static/src/js/fields/field_utils.js | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/addons/web/static/src/js/fields/field_utils.js b/addons/web/static/src/js/fields/field_utils.js index 8fbf24917b1..0d1e70815d5 100644 --- a/addons/web/static/src/js/fields/field_utils.js +++ b/addons/web/static/src/js/fields/field_utils.js @@ -239,18 +239,18 @@ function parseDate (value) { } var date_pattern = time.strftime_to_moment_format(core._t.database.parameters.date_format); var date_pattern_wo_zero = date_pattern.replace('MM','M').replace('DD','D'); - var date = moment(value, [date_pattern, date_pattern_wo_zero, moment.ISO_8601], true); + var date = moment.utc(value, [date_pattern, date_pattern_wo_zero, moment.ISO_8601], true); if (date.isValid() && date.year() >= 1900) { - date.toJSON = time.date_to_str.bind(time, date.toDate()); + date.toJSON = function () {return this.utc().format('YYYY-MM-DD');}; return date; } - date = moment(value, [date_pattern, date_pattern_wo_zero, moment.ISO_8601]); + date = moment.utc(value, [date_pattern, date_pattern_wo_zero, moment.ISO_8601]); if (date.isValid()) { if (date.year() === 0) { date.year(moment.utc().year()); } if (date.year() >= 1900) { - date.toJSON = time.date_to_str.bind(time, date.toDate()); + date.toJSON = function () {return this.utc().format('YYYY-MM-DD');}; return date; } } @@ -274,18 +274,20 @@ function parseDateTime (value) { time_pattern_wo_zero = time_pattern.replace('HH','H').replace('mm','m').replace('ss','s'); var pattern1 = date_pattern + ' ' + time_pattern; var pattern2 = date_pattern_wo_zero + ' ' + time_pattern_wo_zero; - var datetime = moment(value, [pattern1, pattern2, moment.ISO_8601], true); + var datetime = moment.utc(value, [pattern1, pattern2, moment.ISO_8601], true); if (datetime.isValid() && datetime.year() >= 1900) { - datetime.toJSON = time.datetime_to_str.bind(time, datetime.toDate()); + datetime.toJSON = function () { + return this.utc().format('YYYY-MM-DD HH:mm:ss'); + }; return datetime; } - datetime = moment(value, [pattern1, pattern2, moment.ISO_8601]); + datetime = moment.utc(value, [pattern1, pattern2, moment.ISO_8601]); if (datetime.isValid()) { if (datetime.year() === 0) { datetime.year(moment.utc().year()); } if (datetime.year() >= 1900) { - datetime.toJSON = time.datetime_to_str.bind(time, datetime.toDate()); + datetime.toJSON = function () {return this.utc().format('YYYY-MM-DD HH:mm:ss');}; return datetime; } } |
