-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Open
Labels
Description
Timeline view shows items ending one day before when using Date fields
Module
web_timeline
Describe the bug
When using Date fields (not DateTime) for date_start and date_stop in a timeline view, timeline items end one day before the expected end date. The date_stop field is parsed as 00:00:00 of that day, so the item ends at the start of the day instead of including the full day.
To Reproduce
Affected versions:
- Odoo 18.0
- web_timeline 18.0.1.0.1
Steps to reproduce the behavior:
- Create a model with
Datefields (notDateTime) for start and end dates - Create a timeline view with
date_startanddate_stoppointing to these Date fields - Create a record with
date_start = 2025-11-10anddate_end = 2025-11-14 - Open the timeline view
- Observe that the timeline item ends on
2025-11-13(one day before) instead of2025-11-14
Expected behavior
The timeline item should display until the end of 2025-01-14 (23:59:59), showing the full day. When using Date fields, the date_stop should be set to end-of-day (23:59:59) instead of start-of-day (00:00:00).
Additional context
- This affects
Datefields only;DateTimefields work correctly - The issue is in
TimelineModel._get_event_dates()method in/static/src/views/timeline/timeline_model.esm.js - When a
Datefield is parsed, it's converted to a DateTime at 00:00:00, which causes the item to end at the start of the day - The fix should check if
date_stopis aDatefield and set it to end-of-day using.endOf("day")from Luxon
Workaround
A custom patch can be applied to TimelineModel.prototype._get_event_dates to set date_stop to end-of-day when it's a Date field:
patch(TimelineModel.prototype, {
_get_event_dates(record) {
const [date_start, date_stop] = super._get_event_dates(...arguments);
if (date_stop && this.date_stop && this.fields[this.date_stop]) {
const date_stop_field = this.fields[this.date_stop];
if (date_stop_field.type === "date") {
return [date_start, date_stop.endOf("day")];
}
}
return [date_start, date_stop];
}
});