From 3a2c69edbf4015107d5e68104e1c28bf74fcd1d8 Mon Sep 17 00:00:00 2001 From: fw-bot Date: Thu, 10 Oct 2019 13:10:08 +0000 Subject: [PATCH] [FIX] web: use language week_start in datepickers Before this rev., if the week_start param (the first day of week) of the user language was changed, it wasn't reflected on datepickers (however, it worked fine in the calendar view). This rev. makes this work by updating the moment locale with the corresponding param. Fixes #36450 Closes #36532 closes odoo/odoo#38472 X-original-commit: eeb518316f25d652bea3ec6d387db6ad93284fb2 Signed-off-by: Aaron Bohy (aab) --- addons/web/static/src/js/core/session.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/addons/web/static/src/js/core/session.js b/addons/web/static/src/js/core/session.js index 09d765fbc5b..4c8a63dbdb5 100644 --- a/addons/web/static/src/js/core/session.js +++ b/addons/web/static/src/js/core/session.js @@ -207,6 +207,8 @@ var Session = core.Class.extend(mixins.EventDispatcherMixin, { } return loaded.then(function () { return self.load_js(file_list); + }).then(function () { + self._configureLocale(); }); }, load_translations: function () { @@ -361,6 +363,23 @@ var Session = core.Class.extend(mixins.EventDispatcherMixin, { location.reload(); }, + //-------------------------------------------------------------------------- + // Private + //-------------------------------------------------------------------------- + + /** + * Sets first day of week in current locale according to the user language. + * + * @private + */ + _configureLocale: function () { + moment.updateLocale(moment.locale(), { + week: { + dow: (_t.database.parameters.week_start || 0) % 7, + }, + }); + }, + //-------------------------------------------------------------------------- // Handlers //--------------------------------------------------------------------------