[FIX] web: legacy kanbanRecord kinda supports luxon

The new WOWL Kanban view supports that luxon be used in the archs.
Legacy kanban had a similar support but for moment.js

Obviously, new archs can't work with legacy implementation because of this.
This commit aims at providing some sort of hackish support, only valid in
the transition phase.
At least one use case has popped up, that is, when editing such kanban view with Studio.
In that case, there was a crash, which is fixed with this commit.

closes odoo/odoo#103821

X-original-commit: 14f56b324d241f35b742781424535cecf26a218e
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
Signed-off-by: Lucas Perais (lpe) <lpe@odoo.com>
This commit is contained in:
Lucas Perais
2022-10-25 11:07:11 +02:00
parent 2ea245d11e
commit ec86454778
@@ -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,
};
},
/**