From f4e1974d67c776b01329db443d3def05d2ce1bc2 Mon Sep 17 00:00:00 2001 From: David Monjoie Date: Mon, 20 Apr 2015 14:10:10 +0200 Subject: [PATCH] [FIX] web_calendar: fixed counting of days when selection spans multiple weeks As event_obj._length doesn't return the number of days when the selection spans multiple weeks, the test was wrong when the selection ended on the first day of a subsequent week. This fix was originaly written by rha-odoo at 95d344b, but I rewrote it a little. I would have liked a cleaner way of finding how many days there were between the two dates, but I couldn't find anything better, considering I didn't want to create new objects just for that test. Fixes opw 614703. --- addons/web_calendar/static/src/js/calendar.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/web_calendar/static/src/js/calendar.js b/addons/web_calendar/static/src/js/calendar.js index 2c7edaf13e6..afc3ce4a0e8 100644 --- a/addons/web_calendar/static/src/js/calendar.js +++ b/addons/web_calendar/static/src/js/calendar.js @@ -482,7 +482,8 @@ instance.web_calendar.CalendarView = instance.web.View.extend({ this.is_slow_open = true; if (this.current_mode() === 'month') { event_obj['start_date'].addHours(8); - if (event_obj._length === 1) { + var timediff = Math.abs(event_obj['end_date'] - event_obj['start_date']); + if (timediff <= 24*60*60*1000) { // If it spans one day or less event_obj['end_date'] = new Date(event_obj['start_date']); event_obj['end_date'].addHours(1); } else {