summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js
diff options
context:
space:
mode:
authorNasreddin (bon) <bon@odoo.com>2021-03-08 12:57:03 +0000
committerLucas Perais (lpe) <lpe@odoo.com>2021-03-17 16:08:32 +0000
commite2c46bb80e1e312dd34ac554d79813ef35282e62 (patch)
tree186975fd56323a9426c682bf390180e81c4248ab /addons/web/static/src/js
parent629ce193e4725919c1aeede000517564f0e8adf1 (diff)
[FIX] web: compute default locale of Date(Time)Picker at the right time
Issue - Install "Accounting" - Change user language to arabic - Go to Customer Invoices list view - Try to filter on field "Created On" Traceback is raised from the DatePicker Component Cause The cause is two fold: There is an issue in moment that behaves abnormally when its internals are not able to extract the month in a locale, and, instead of returning an invalid moment, it returns a valid moment with the month set to January which just happens to be the first month of moment's default locale ref: https://github.com/moment/moment/issues/5600 Secondly, the defaultProps "locale" of the DatePicker was set to moment.locale() at the file's initial loading, that is, before any user locale parameters were loaded The bootstrap datepicker was then set with the wrong locale, and the case fell under moment's issue After this commit, the locale of the DatePicker is always the one of the user, and there is no traceback opw-2460156 closes odoo/odoo#67320 Signed-off-by: Aaron Bohy (aab) <aab@odoo.com> Co-authored-by: Lucas Perais <lpe@odoo.com>
Diffstat (limited to 'addons/web/static/src/js')
-rw-r--r--addons/web/static/src/js/components/datepicker.js4
1 files changed, 2 insertions, 2 deletions
diff --git a/addons/web/static/src/js/components/datepicker.js b/addons/web/static/src/js/components/datepicker.js
index a11d51b5021..94ce7ece4fe 100644
--- a/addons/web/static/src/js/components/datepicker.js
+++ b/addons/web/static/src/js/components/datepicker.js
@@ -178,7 +178,7 @@ odoo.define('web.DatePickerOwl', function (require) {
today: 'fa fa-calendar-check-o',
up: 'fa fa-chevron-up',
},
- locale: moment.locale(),
+ get locale() {return moment.locale();},
maxDate: moment({ y: 9999, M: 11, d: 31 }),
minDate: moment({ y: 1000 }),
useCurrent: false,
@@ -248,7 +248,7 @@ odoo.define('web.DatePickerOwl', function (require) {
}
}
- DateTimePicker.defaultProps = Object.assign({}, DatePicker.defaultProps, {
+ DateTimePicker.defaultProps = Object.assign(Object.create(DatePicker.defaultProps), {
buttons: {
showClear: false,
showClose: true,