From 657d5493f8a0f42cdbc6a4c598361d6366aef812 Mon Sep 17 00:00:00 2001 From: "Lopes Marc (loma)" Date: Fri, 8 Dec 2023 16:02:21 +0100 Subject: [PATCH] [FIX] website_slides: fix datetimeObj.getTime is not a function HOW TO REPRODUCE ================ - Don't need to login - From Odoo front-end, go to Courses > Trees, Wood and Gardens > Main Trees Categories - You get the following client error: Uncaught Promise > datetimeObj.getTime is not a function HOW TO SOLVE: ============ Unlike standard JS equivalent, luxon datetime objects don't have a getTime() function. Replace it by valueOf() function. Also, remove calls to `DateTime.fromJSDate().formatting_fn()` by luxon equivalent functions. see bb09cf76e32b20864dc45eacf912d2c6f26768ef task-3632077 closes odoo/odoo#145573 Signed-off-by: Thibault Delavallee (tde) --- addons/website_slides/static/src/js/slides.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/addons/website_slides/static/src/js/slides.js b/addons/website_slides/static/src/js/slides.js index 964eebfcd10..07de74b013b 100644 --- a/addons/website_slides/static/src/js/slides.js +++ b/addons/website_slides/static/src/js/slides.js @@ -2,7 +2,6 @@ import publicWidget from '@web/legacy/js/public/public_widget'; import { deserializeDateTime } from "@web/core/l10n/dates"; -const { DateTime } = luxon; publicWidget.registry.websiteSlides = publicWidget.Widget.extend({ selector: '#wrapwrap', @@ -20,10 +19,10 @@ publicWidget.registry.websiteSlides = publicWidget.Widget.extend({ // if presentation 7 days, 24 hours, 60 min, 60 second, 1000 millis old(one week) // then return fix formate string else timeago var displayStr = ''; - if (datetimeObj && new Date().getTime() - datetimeObj.getTime() > 7 * 24 * 60 * 60 * 1000) { - displayStr = DateTime.fromJSDate(datetimeObj).toFormat('DD'); + if (datetimeObj && new Date().getTime() - datetimeObj.valueOf() > 7 * 24 * 60 * 60 * 1000) { + displayStr = datetimeObj.toFormat('DD'); } else { - displayStr = DateTime.fromJSDate(datetimeObj).toRelative(); + displayStr = datetimeObj.toRelative(); } $(el).text(displayStr); });