Skip to content

web_timeline: Timeline view shows items ending one day before when using Date fields #3349

@vijoin

Description

@vijoin

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:

  1. Create a model with Date fields (not DateTime) for start and end dates
  2. Create a timeline view with date_start and date_stop pointing to these Date fields
  3. Create a record with date_start = 2025-11-10 and date_end = 2025-11-14
  4. Open the timeline view
  5. Observe that the timeline item ends on 2025-11-13 (one day before) instead of 2025-11-14
Image Image Image Image

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];
    }
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions