diff --git a/addons/mail/models/mail_message.py b/addons/mail/models/mail_message.py index 129e6b0603e..d80dc68f2fe 100644 --- a/addons/mail/models/mail_message.py +++ b/addons/mail/models/mail_message.py @@ -110,6 +110,7 @@ class Message(models.Model): ('email', 'Email'), ('comment', 'Comment'), ('notification', 'System notification'), + ('auto_comment', 'Automated Targeted Notification'), ('user_notification', 'User Specific Notification')], 'Type', required=True, default='email', help="Message type: email for email message, notification for system " diff --git a/addons/mail/models/mail_thread.py b/addons/mail/models/mail_thread.py index 3de79540e91..ac1d0023ab1 100644 --- a/addons/mail/models/mail_thread.py +++ b/addons/mail/models/mail_thread.py @@ -670,6 +670,7 @@ class MailThread(models.AbstractModel): continue composition_mode = post_kwargs.pop('composition_mode', default_composition_mode) + post_kwargs.setdefault('message_type', 'auto_comment') if composition_mode == 'mass_mail': cleaned_self.message_mail_with_source(template, **post_kwargs) else: @@ -1646,17 +1647,24 @@ class MailThread(models.AbstractModel): stored_date = datetime.datetime.now() msg_dict['date'] = stored_date.strftime(tools.DEFAULT_SERVER_DATETIME_FORMAT) - parent_message = self._get_parent_message(msg_dict) - if parent_message: - msg_dict['parent_id'] = parent_message.id - msg_dict['is_internal'] = bool(parent_message.subtype_id and parent_message.subtype_id.internal) - + msg_dict.update(self._message_parse_extract_from_parent(self._get_parent_message(msg_dict))) msg_dict['is_bounce'] = self._message_parse_is_bounce(message, msg_dict) msg_dict.update(self._message_parse_extract_payload(message, msg_dict, save_original=save_original)) if msg_dict['is_bounce']: msg_dict.update(self._message_parse_extract_bounce(message, msg_dict)) return msg_dict + def _message_parse_extract_from_parent(self, parent_message): + """Derive message values from the parent.""" + if parent_message: + parent_is_internal = bool(parent_message.subtype_id and parent_message.subtype_id.internal) + parent_is_auto_comment = parent_message.message_type == 'auto_comment' + return { + 'parent_id': parent_message.id, + 'is_internal': parent_is_internal and not parent_is_auto_comment + } + return {} + def _get_bounced_message_data(self, message, message_dict): """Find the original and the bounced email references based on an incoming email. diff --git a/addons/mail/static/src/core/message_model.js b/addons/mail/static/src/core/message_model.js index 8183f873e20..287db295303 100644 --- a/addons/mail/static/src/core/message_model.js +++ b/addons/mail/static/src/core/message_model.js @@ -118,6 +118,10 @@ export class Message { return this.datetime.toLocaleString(DateTime.DATETIME_SHORT); } + get isAutomatedMessage() { + return this.type === "auto_comment"; + } + get isSelfMentioned() { return this.recipients.some((recipient) => recipient === this._store.self); } diff --git a/addons/mail/static/src/core_ui/message.js b/addons/mail/static/src/core_ui/message.js index aa9b7b86d30..fe360529f6b 100644 --- a/addons/mail/static/src/core_ui/message.js +++ b/addons/mail/static/src/core_ui/message.js @@ -190,6 +190,9 @@ export class Message extends Component { if (this.props.message.type === "notification") { return _t("System notification"); } + if (this.props.message.type === "auto_comment") { + return _t("Automated message"); + } if (!this.props.message.isDiscussion && this.props.message.type !== "user_notification") { return _t("Note"); } diff --git a/addons/mail/static/src/core_ui/message.xml b/addons/mail/static/src/core_ui/message.xml index 590ac0758aa..a81d71b6644 100644 --- a/addons/mail/static/src/core_ui/message.xml +++ b/addons/mail/static/src/core_ui/message.xml @@ -132,9 +132,9 @@ 'position-absolute top-0': !env.inDiscussApp, 'start-0 ms-3': isAlignedRight, 'end-0 me-3': env.inChatWindow and !isAlignedRight or env.inChatter, - 'mt-n4': env.inChatter and (message.isDiscussion or message.isNotification), - 'mt-n5': env.inChatter and !(message.isDiscussion or message.isNotification), - 'mt-2': env.inDiscussApp and (message.isDiscussion or message.isNotification), + 'mt-n4': env.inChatter and (message.isDiscussion or message.isNotification or message.isAutomatedMessage), + 'mt-n5': env.inChatter and !(message.isDiscussion or message.isNotification or message.isAutomatedMessage), + 'mt-2': env.inDiscussApp and (message.isDiscussion or message.isNotification or message.isAutomatedMessage), 'mt-n3': env.inChatWindow, 'ms-2': env.inDiscussApp, 'invisible': !isActive, @@ -142,7 +142,7 @@ }" >
diff --git a/addons/mail/static/src/core_ui/message_reactions.xml b/addons/mail/static/src/core_ui/message_reactions.xml index 322bd70b490..261a09a3f83 100644 --- a/addons/mail/static/src/core_ui/message_reactions.xml +++ b/addons/mail/static/src/core_ui/message_reactions.xml @@ -4,9 +4,9 @@
+ t-attf-class="{{ (props.message.isDiscussion or props.message.isAutomatedMessage) ? 'mt-n2' : 'mt-1' }}">