summaryrefslogtreecommitdiff
path: root/addons/web/static/src
diff options
context:
space:
mode:
authorAdrien Dieudonne <adr@odoo.com>2017-08-10 15:52:49 +0200
committerAaron Bohy <aab@odoo.com>2017-08-17 17:40:41 +0200
commitbbf63b0b563dbf55c07fb0c5bfe5cf17f3b84fb8 (patch)
tree6206f401e0f6eafb9fc984717e17473832e262d1 /addons/web/static/src
parentf5b7ad80fcfd1638cb7ea019a38871c3b8438e36 (diff)
[FIX] web: Calendar: correctly display events
Before this rev., the events in Calendar views (month mode) weren't correctly displayed: the last day of the event wasn't displayed as being part of the event. For instance, in leaves, a leave of 3 days from the 16th of Augustus until the 18th was only displayed over the 16th and the 17th. Moreover, when an event was created from a Calendar view with option all_day=False, the default start and end dates weren't correctly computed according to the user timezone, which could lead to the creation of multiple days event whereas the user clicked on a specific day. For instance, with timezone GMT+2, when clicking on the 18th of Augustus in the Leave Calendar view (month mode), it opened a dialog for the creation of a 2-day leave from the 18th to the 19th. This rev. fixes those two issues.
Diffstat (limited to 'addons/web/static/src')
-rw-r--r--addons/web/static/src/js/views/calendar/calendar_model.js18
1 files changed, 14 insertions, 4 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 ed02983d957..e338ae55ece 100644
--- a/addons/web/static/src/js/views/calendar/calendar_model.js
+++ b/addons/web/static/src/js/views/calendar/calendar_model.js
@@ -45,20 +45,26 @@ return AbstractModel.extend({
if (event.allDay || end.diff(start) % 86400000 === 0) {
event.allDay = true;
- if (this.scale === 'month') {
+ if (this.data.scale === 'month') {
+ // In month, FullCalendar gives the end day as the
+ // next day at midnight (instead of 23h59).
+ end.add(-1, 'days');
if (event.r_start) {
start.hours(event.r_start.hours())
.minutes(event.r_start.minutes())
.seconds(event.r_start.seconds())
.utc();
- end.add(-1, 'days')
- .hours(event.r_end.hours())
+ end.hours(event.r_end.hours())
.minutes(event.r_end.minutes())
.seconds(event.r_end.seconds())
.utc();
- } else {
+ } else if (this.mapping.all_day) {
start.utc();
end.utc();
+ } else {
+ // default hours in the user's timezone
+ start.hours(7).add(-this.getSession().getTZOffset(start), 'minutes');
+ end.hours(19).add(-this.getSession().getTZOffset(end), 'minutes');
}
} else if (this.mapping.all_day) {
start.startOf('day');
@@ -622,6 +628,10 @@ return AbstractModel.extend({
// r.start = date_start.format('YYYY-MM-DD');
// r.end = date_stop.format('YYYY-MM-DD');
} else if (this.data.scale === 'month' && this.fields[this.mapping.date_start].type !== 'date') {
+ // In month, FullCalendar gives the end day as the
+ // next day at midnight (instead of 23h59).
+ date_stop.add(1, 'days');
+
// allow to resize in month mode
r.reset_allday = r.allDay;
r.allDay = true;