summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/views/calendar
diff options
context:
space:
mode:
authorNicolas Lempereur <nle@odoo.com>2019-11-12 17:18:46 +0000
committerfw-bot <otis@odoo.com>2019-11-15 11:11:49 +0000
commitdfc92c66a67fee0bdcbe29d98beca453a8f0349a (patch)
tree2672757c260a4aa174fad5a0d1d2188589c06212 /addons/web/static/src/js/views/calendar
parentabc80eff18a58d2a4bfe91e5f0c51d08d31d0d79 (diff)
[FIX] web: week view ok if week start not sunday/monday
Currently, if the first week day was Saturday the calendar week view would possibly get the wrong week. This is because current heuristic would get date of current week from 6 (Saturday) to 12 (Sunday). Thus if we were: - on Friday 14th, we would have a week day ranges: 15-21 (wrong) - on Saturday 15th, we would have a week day ranges: 15-21 (ok) - on Sunday 16th, we would have a week day ranges: 22-28 (wrong) So it would only get the right range when getting range from saturday. If a week: - start on monday, the week range would only be wrong on sunday. - start on sunday, the week range would always be alright. Added test without the fix fail: - CalendarView: Saturday week start week mode The domain to search events in should be correct (domain range 14-20 instead of correct 07-13 whilst the day was 12th) - CalendarView: Monday week start week mode The domain to search events in should be correct (domain range 16-22 instead of correct 09-15 whilst the day was 15th) opw-2091448 closes #40244 closes odoo/odoo#40327 X-original-commit: 6c3d74846581d6c1bfc0c6e3a7104440515ddbc5 Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
Diffstat (limited to 'addons/web/static/src/js/views/calendar')
-rw-r--r--addons/web/static/src/js/views/calendar/calendar_model.js11
1 files changed, 9 insertions, 2 deletions
diff --git a/addons/web/static/src/js/views/calendar/calendar_model.js b/addons/web/static/src/js/views/calendar/calendar_model.js
index dc27ff1bfdb..a12f8f0469d 100644
--- a/addons/web/static/src/js/views/calendar/calendar_model.js
+++ b/addons/web/static/src/js/views/calendar/calendar_model.js
@@ -297,8 +297,15 @@ return AbstractModel.extend({
this.data.end_date = this.data.start_date.clone().add(5, 'week').day(this.week_stop).endOf('day');
break;
case 'week':
- this.data.start_date = this.data.start_date.clone().day(this.week_start).startOf('day');
- this.data.end_date = this.data.end_date.clone().day(this.week_stop).endOf('day');
+ var weekStart = this.data.start_date.clone().startOf('week');
+ var weekStartDay = this.week_start;
+ if (this.data.start_date.day() < this.week_start) {
+ // The week's first day is after our current day
+ // Then we should go back to the previous week
+ weekStartDay -= 7;
+ }
+ this.data.start_date = this.data.start_date.clone().day(weekStartDay).startOf('day');
+ this.data.end_date = this.data.end_date.clone().day(weekStartDay + 6).endOf('day');
break;
default:
this.data.start_date = this.data.start_date.clone().startOf('day');