diff options
| author | Christophe Simonis <chs@odoo.com> | 2017-01-23 14:33:53 +0100 |
|---|---|---|
| committer | Christophe Simonis <chs@odoo.com> | 2017-01-23 14:33:53 +0100 |
| commit | 6c4389df41fb29f9707b205a8dcca13b3bf8a322 (patch) | |
| tree | b06358fdcff3268574c9ccda8cb36d9f94eb09dd /addons/web/static/src/js/framework | |
| parent | 255de893300d73670a15a102e85162ae48084d7c (diff) | |
| parent | 6804085b8ceb1411a23db65477f84a959f8c5bf7 (diff) | |
[MERGE] forward port branch 10.0 up to 6804085b8ce
Diffstat (limited to 'addons/web/static/src/js/framework')
| -rw-r--r-- | addons/web/static/src/js/framework/formats.js | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/addons/web/static/src/js/framework/formats.js b/addons/web/static/src/js/framework/formats.js index d084b285f6c..479fa1082cd 100644 --- a/addons/web/static/src/js/framework/formats.js +++ b/addons/web/static/src/js/framework/formats.js @@ -161,26 +161,30 @@ function parse_value (value, descriptor, value_if_empty) { return parse_value(value, {type: "float"}); case 'datetime': var datetime = moment(value, [date_pattern + ' ' + time_pattern, date_pattern_wo_zero + ' ' + time_pattern_wo_zero, moment.ISO_8601], true); - if (datetime.isValid()) + if (datetime.isValid() && datetime.year() >= 1900) return time.datetime_to_str(datetime.toDate()); datetime = moment(value, [date_pattern + ' ' + time_pattern, date_pattern_wo_zero + ' ' + time_pattern_wo_zero, moment.ISO_8601]); if (datetime.isValid()) { if (datetime.year() === 0) { datetime.year(moment.utc().year()); } - return time.datetime_to_str(datetime.toDate()); + if (datetime.year() >= 1900) { + return time.datetime_to_str(datetime.toDate()); + } } throw new Error(_.str.sprintf(_t("'%s' is not a correct datetime"), value)); case 'date': var date = moment(value, [date_pattern, date_pattern_wo_zero, moment.ISO_8601], true); - if (date.isValid()) + if (date.isValid() && date.year() >= 1900) return time.date_to_str(date.toDate()); date = moment(value, [date_pattern, date_pattern_wo_zero, moment.ISO_8601]); if (date.isValid()) { if (date.year() === 0) { date.year(moment.utc().year()); } - return time.date_to_str(date.toDate()); + if (date.year() >= 1900) { + return time.date_to_str(date.toDate()); + } } throw new Error(_.str.sprintf(_t("'%s' is not a correct date"), value)); case 'time': |
