diff options
| author | Harpritsinh Sisodiya <hsi@odoo.com> | 2020-05-15 14:29:17 +0000 |
|---|---|---|
| committer | Aaron Bohy <aab@odoo.com> | 2020-07-28 14:02:10 +0000 |
| commit | 6aa6c321a6cfc08e5490781c4fc7ee62beeebb15 (patch) | |
| tree | b7a47b11ca4bdbdc148db850a9536c0bc78a2bec /addons/web/static/src/js/fields | |
| parent | 684b628c5acc298af83791fbaf8da0b774140425 (diff) | |
[IMP] web: remove min date limitation of year 1900
Before this commit, user could not selecta a date before year 1900.
This was an historical limitation due to python < 3.2 that didn't
support dates before 1900.
After this commit, user can select any date, user can select any
date from 01/01/0001.
taskID: 2166761
Fixes #41788
Closes #43055
closes odoo/odoo#51406
Signed-off-by: Géry Debongnie (ged) <ged@openerp.com>
Co-authored-by: Mohammed Shekha <msh@odoo.com>
Co-authored-by: Aaron Bohy <aab@odoo.com>
Diffstat (limited to 'addons/web/static/src/js/fields')
| -rw-r--r-- | addons/web/static/src/js/fields/field_utils.js | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/addons/web/static/src/js/fields/field_utils.js b/addons/web/static/src/js/fields/field_utils.js index b62a3db7921..8f8b9bbb2ab 100644 --- a/addons/web/static/src/js/fields/field_utils.js +++ b/addons/web/static/src/js/fields/field_utils.js @@ -431,9 +431,10 @@ function parseDate(value, field, options) { return false; } var datePattern = time.getLangDateFormat(); - var datePatternWoZero = datePattern.replace('MM','M').replace('DD','D'); + var datePatternWoZero = datePattern.replace('MM', 'M').replace('DD', 'D'); var date; if (options && options.isUTC) { + value = value.padStart(10, "0"); // server may send "932-10-10" for "0932-10-10" on some OS date = moment.utc(value); } else { date = moment.utc(value, [datePattern, datePatternWoZero, moment.ISO_8601]); @@ -442,12 +443,10 @@ function parseDate(value, field, options) { if (date.year() === 0) { date.year(moment.utc().year()); } - if (date.year() >= 1900) { - date.toJSON = function () { - return this.clone().locale('en').format('YYYY-MM-DD'); - }; - return date; - } + date.toJSON = function () { + return this.clone().locale('en').format('YYYY-MM-DD'); + }; + return date; } throw new Error(_.str.sprintf(core._t("'%s' is not a correct date"), value)); } @@ -489,12 +488,10 @@ function parseDateTime(value, field, options) { if (datetime.year() === 0) { datetime.year(moment.utc().year()); } - if (datetime.year() >= 1900) { - datetime.toJSON = function () { - return this.clone().locale('en').format('YYYY-MM-DD HH:mm:ss'); - }; - return datetime; - } + datetime.toJSON = function () { + return this.clone().locale('en').format('YYYY-MM-DD HH:mm:ss'); + }; + return datetime; } throw new Error(_.str.sprintf(core._t("'%s' is not a correct datetime"), value)); } |
