From b69410f4b5420b62336dea61550222f08e01afb6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Houz=C3=A9fa=20Abbasbhay?= Date: Thu, 21 Mar 2024 12:12:56 +0100 Subject: [PATCH] [IMP] web_timeline: Handle inverted date ranges Inverted dates make no functional sense, but when they do happen, this change allows displaying them as single points in the timeline (same as when begin=end). We currently do have such demo data when installing project_timeline. --- web_timeline/static/src/js/timeline_renderer.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/web_timeline/static/src/js/timeline_renderer.js b/web_timeline/static/src/js/timeline_renderer.js index 408ec80de..14d387ed6 100644 --- a/web_timeline/static/src/js/timeline_renderer.js +++ b/web_timeline/static/src/js/timeline_renderer.js @@ -531,9 +531,9 @@ odoo.define("web_timeline.TimelineRenderer", function (require) { evt: evt, style: `background-color: ${this.color};`, }; - // Check if the event is instantaneous, - // if so, display it with a point on the timeline (no 'end') - if (date_stop && !moment(date_start).isSame(date_stop)) { + // Only specify range end when there actually is one. + // ➔ Instantaneous events / those with inverted dates are displayed as points. + if (date_stop && moment(date_start).isBefore(date_stop)) { r.end = date_stop; } this.color = null;