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
Date fields (not DateTime) for start and end dates
- Create a timeline view with
date_start and date_stop pointing to these Date fields
- Create a record with
date_start = 2025-11-10 and date_end = 2025-11-14
- Open the timeline view
- Observe that the timeline item ends on
2025-11-13 (one day before) instead of 2025-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
Date fields only; DateTime fields work correctly
- The issue is in
TimelineModel._get_event_dates() method in /static/src/views/timeline/timeline_model.esm.js
- When a
Date field 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_stop is a Date field 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];
}
});
Timeline view shows items ending one day before when using Date fields
Module
web_timeline
Describe the bug
When using
Datefields (notDateTime) fordate_startanddate_stopin a timeline view, timeline items end one day before the expected end date. Thedate_stopfield 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:
Steps to reproduce the behavior:
Datefields (notDateTime) for start and end datesdate_startanddate_stoppointing to these Date fieldsdate_start = 2025-11-10anddate_end = 2025-11-142025-11-13(one day before) instead of2025-11-14Expected behavior
The timeline item should display until the end of
2025-01-14(23:59:59), showing the full day. When usingDatefields, thedate_stopshould be set to end-of-day (23:59:59) instead of start-of-day (00:00:00).Additional context
Datefields only;DateTimefields work correctlyTimelineModel._get_event_dates()method in/static/src/views/timeline/timeline_model.esm.jsDatefield is parsed, it's converted to a DateTime at 00:00:00, which causes the item to end at the start of the daydate_stopis aDatefield and set it to end-of-day using.endOf("day")from LuxonWorkaround
A custom patch can be applied to
TimelineModel.prototype._get_event_datesto setdate_stopto end-of-day when it's a Date field: