diff --git a/addons/mail/i18n/mail.pot b/addons/mail/i18n/mail.pot index 3145a900792..85ab39b74b0 100644 --- a/addons/mail/i18n/mail.pot +++ b/addons/mail/i18n/mail.pot @@ -1438,6 +1438,13 @@ msgstr "" msgid "Click on your message" msgstr "" +#. module: mail +#. openerp-web +#: code:addons/mail/static/src/components/message_in_reply_to_view/message_in_reply_to_view.xml:0 +#, python-format +msgid "Click to see the attachments" +msgstr "" + #. module: mail #. openerp-web #: code:addons/mail/static/src/components/attachment_viewer/attachment_viewer.xml:0 @@ -4793,6 +4800,12 @@ msgstr "" msgid "Only logged notes can have their content updated on model '%s'" msgstr "" +#. module: mail +#: code:addons/mail/models/mail_thread.py:0 +#, python-format +msgid "Only messages type comment can have their content updated" +msgstr "" + #. module: mail #: code:addons/mail/models/mail_channel.py:0 #, python-format diff --git a/addons/mail/static/src/components/message_in_reply_to_view/message_in_reply_to_view.xml b/addons/mail/static/src/components/message_in_reply_to_view/message_in_reply_to_view.xml index 1326c70f9f3..df427432222 100644 --- a/addons/mail/static/src/components/message_in_reply_to_view/message_in_reply_to_view.xml +++ b/addons/mail/static/src/components/message_in_reply_to_view/message_in_reply_to_view.xml @@ -5,7 +5,15 @@ @ - + + + + + + Click to see the attachments + + + Original message was deleted diff --git a/addons/mail/static/src/models/message/message.js b/addons/mail/static/src/models/message/message.js index 8019b901fcf..8e39160ad0f 100644 --- a/addons/mail/static/src/models/message/message.js +++ b/addons/mail/static/src/models/message/message.js @@ -367,6 +367,13 @@ registerModel({ _computeFailureNotifications() { return replace(this.notifications.filter(notifications => notifications.isFailure)); }, + /** + * @private + * @returns {boolean} + */ + _computeHasAttachments() { + return this.attachments.length > 0; + }, /** * @returns {boolean} */ @@ -388,6 +395,21 @@ registerModel({ this.messaging.currentGuest === this.guestAuthor ); }, + /** + * @private + * @returns {boolean} + */ + _computeIsBodyEmpty() { + return ( + !this.body || + [ + '', + '

', + '


', + '


', + ].includes(this.body.replace(/\s/g, '')) + ); + }, /** * @private * @returns {boolean} @@ -417,18 +439,9 @@ registerModel({ * @returns {boolean} */ _computeIsEmpty() { - const isBodyEmpty = ( - !this.body || - [ - '', - '

', - '


', - '


', - ].includes(this.body.replace(/\s/g, '')) - ); return ( - isBodyEmpty && - this.attachments.length === 0 && + this.isBodyEmpty && + !this.hasAttachments && this.tracking_value_ids.length === 0 && !this.subtype_description ); @@ -587,6 +600,12 @@ registerModel({ guestAuthor: many2one('Guest', { inverse: 'authoredMessages', }), + /** + * States whether the message has some attachments. + */ + hasAttachments: attr({ + compute: '_computeHasAttachments', + }), /** * Determines whether the message has a reaction icon. */ @@ -601,6 +620,14 @@ registerModel({ compute: '_computeIsCurrentUserOrGuestAuthor', default: false, }), + /** + * States if the body field is empty, regardless of editor default + * html content. To determine if a message is fully empty, use + * `isEmpty`. + */ + isBodyEmpty: attr({ + compute: '_computeIsBodyEmpty', + }), /** * States whether `body` and `subtype_description` contain similar * values. diff --git a/addons/mail/static/src/models/message_in_reply_to_view/message_in_reply_to_view.js b/addons/mail/static/src/models/message_in_reply_to_view/message_in_reply_to_view.js index bb866c5ef35..aa2f3e8774e 100644 --- a/addons/mail/static/src/models/message_in_reply_to_view/message_in_reply_to_view.js +++ b/addons/mail/static/src/models/message_in_reply_to_view/message_in_reply_to_view.js @@ -1,7 +1,7 @@ /** @odoo-module **/ import { registerModel } from '@mail/model/model_core'; -import { one2one } from '@mail/model/model_field'; +import { attr, one2one } from '@mail/model/model_field'; import { replace } from '@mail/model/model_field_command'; import { markEventHandled } from '@mail/utils/utils'; @@ -35,8 +35,36 @@ registerModel({ } threadView.addComponentHint('highlight-reply', parentMessageView); }, + /** + * @private + * @returns {boolean} + */ + _computeHasAttachmentBackLink() { + const parentMessage = this.messageView.message.parentMessage; + return parentMessage.isBodyEmpty && parentMessage.hasAttachments; + }, + /** + * @private + * @returns {boolean} + */ + _computeHasBodyBackLink() { + return !this.messageView.message.parentMessage.isBodyEmpty; + }, }, fields: { + /** + * Determines if the reply has a back link to an attachment only + * message. + */ + hasAttachmentBackLink: attr({ + compute: '_computeHasAttachmentBackLink', + }), + /** + * Determines if the reply has a back link to a non-empty body. + */ + hasBodyBackLink: attr({ + compute: '_computeHasBodyBackLink', + }), messageView: one2one('MessageView', { inverse: 'messageInReplyToView', readonly: true,