diff --git a/addons/web/static/src/legacy/js/views/kanban/kanban_record.js b/addons/web/static/src/legacy/js/views/kanban/kanban_record.js index 828fd89f839..51a53a71273 100644 --- a/addons/web/static/src/legacy/js/views/kanban/kanban_record.js +++ b/addons/web/static/src/legacy/js/views/kanban/kanban_record.js @@ -26,6 +26,25 @@ var NB_KANBAN_RECORD_COLORS = KANBAN_RECORD_COLORS.length; const { Component } = owl; +const { DateTime } = luxon; +// As the name suggests, this is a hack that allows archs that work in the new +// WOWL kanban views to be instanciated with legacy code. This is one of some +// hacks to make this work, until the legacy code base is deleted. +// It only exposes `fromISO` and `local` of DateTime, to limit the damage and complexity. +const hackishLuxon = { + DateTime: { + fromISO(text, opt) { + // In legacy text should be a Date (native JS) object (see @_transformRecord) + const res = DateTime.fromJSDate(text, "UTC"); + if (!res.isValid) { + throw new Error("Invalid Hackish luxon instance in legacy KanbanRecord") + } + return res; + }, + local: DateTime.local, + } +}; + var KanbanRecord = Widget.extend(WidgetAdapterMixin, { events: { 'click .oe_kanban_action': '_onKanbanActionClicked', @@ -593,6 +612,7 @@ var KanbanRecord = Widget.extend(WidgetAdapterMixin, { record: this.record, user_context: this.getSession().user_context, widget: this, + luxon: hackishLuxon, }; }, /**