diff --git a/addons/mail/static/src/components/message/message.js b/addons/mail/static/src/components/message/message.js index 85732388e8c..b3efd700d4b 100644 --- a/addons/mail/static/src/components/message/message.js +++ b/addons/mail/static/src/components/message/message.js @@ -8,7 +8,6 @@ import { isEventHandled, markEventHandled } from '@mail/utils/utils'; import { _lt } from 'web.core'; import Popover from "web.Popover"; -import { getLangDatetimeFormat } from 'web.time'; const { Component, onWillUnmount, useRef, useState } = owl; @@ -86,15 +85,6 @@ export class Message extends Component { // Public //-------------------------------------------------------------------------- - /** - * Get the date time of the message at current user locale time. - * - * @returns {string} - */ - get datetime() { - return this.messageView.message.date.format(getLangDatetimeFormat()); - } - /** * Whether the message is "active", ie: hovered or clicked, and should * display additional things (date in sidebar, message actions, etc.) diff --git a/addons/mail/static/src/components/message/message.xml b/addons/mail/static/src/components/message/message.xml index efc34d3690d..ed6b6ea99ae 100644 --- a/addons/mail/static/src/components/message/message.xml +++ b/addons/mail/static/src/components/message/message.xml @@ -83,7 +83,7 @@ -
+
-
diff --git a/addons/mail/static/src/models/message.js b/addons/mail/static/src/models/message.js index d83270485ab..96b19cbea5f 100644 --- a/addons/mail/static/src/models/message.js +++ b/addons/mail/static/src/models/message.js @@ -9,7 +9,7 @@ import { addLink, htmlToTextContentInline, parseAndTransform, timeFromNow } from import { session } from '@web/session'; import { format } from 'web.field_utils'; -import { str_to_datetime } from 'web.time'; +import { getLangDatetimeFormat, str_to_datetime } from 'web.time'; registerModel({ name: 'Message', @@ -383,6 +383,16 @@ registerModel({ } return timeFromNow(this.date); }, + /** + * @private + * @returns {string|FieldCommand} + */ + _computeDatetime() { + if (!this.date) { + return clear(); + } + return this.date.format(getLangDatetimeFormat()); + }, /** * @returns {boolean} */ @@ -717,6 +727,12 @@ registerModel({ dateFromNow: attr({ compute: '_computeDateFromNow', }), + /** + * The date time of the message at current user locale time. + */ + datetime: attr({ + compute: '_computeDatetime', + }), email_from: attr(), failureNotifications: many('Notification', { compute: '_computeFailureNotifications',