diff options
| author | Lucas Perais (lpe) <lpe@odoo.com> | 2019-01-24 16:39:41 +0000 |
|---|---|---|
| committer | Lucas Perais (lpe) <lpe@odoo.com> | 2019-01-29 08:52:28 +0000 |
| commit | e7bbdf884fa113bda1c7dd9d16ac17ac6429a013 (patch) | |
| tree | 14446dbbfbba0b590dc64f19cb58e70a457a1f4e /addons/web/static/src | |
| parent | 10d558ef2be2eb6915f0c52e8ea9561df91a9b1d (diff) | |
[FIX] web: calendar: take locale to format dates
Before this commit, when opening the calendar view with a specific locale
in the "week" view
the days were translated but the date format was wrong and fell back to english
This was because the translated terms were passed explicitly, but the locale did not
get passed
After this commit, we do what it takes to pass the locale to fullcalendar
and the dates are formatted with the right pattern
Also, there may be a bug in fullcalendar, because just passing the locale in the options
won't work, it should be instanciated first in fullcalendar's "locales cache"
OPW 1922092
closes odoo/odoo#30530
Diffstat (limited to 'addons/web/static/src')
| -rw-r--r-- | addons/web/static/src/js/views/calendar/calendar_renderer.js | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/addons/web/static/src/js/views/calendar/calendar_renderer.js b/addons/web/static/src/js/views/calendar/calendar_renderer.js index c2c90ea7e62..03c59885fbe 100644 --- a/addons/web/static/src/js/views/calendar/calendar_renderer.js +++ b/addons/web/static/src/js/views/calendar/calendar_renderer.js @@ -362,6 +362,11 @@ return AbstractRenderer.extend({ this.$calendar = this.$(".o_calendar_widget"); + // This seems like a workaround but apparently passing the locale + // in the options is not enough. We should initialize it beforehand + var locale = moment.locale(); + $.fullCalendar.locale(locale); + //Documentation here : http://arshaw.com/fullcalendar/docs/ var fc_options = $.extend({}, this.state.fc_options, { eventDrop: function (event) { @@ -414,6 +419,7 @@ return AbstractRenderer.extend({ height: 'parent', unselectAuto: false, isRTL: _t.database.parameters.direction === "rtl", + locale: locale, // reset locale when fullcalendar has already been instanciated before now }); this.$calendar.fullCalendar(fc_options); |
