[IMP] mail: improve returned values of _message_compute_author
Purpose of this commit is to ease the use of mail.thread tool method _message_compute_author. Instead of returning a dict with two values and having to unpack them, directly return a tuple with both author and email_from values. All calls and return management are the same in mail. Let us simplify code. Task ID 1853147 PR #32243
This commit is contained in:
@@ -1827,8 +1827,7 @@ class MailThread(models.AbstractModel):
|
||||
raise ValueError('message_post partner_ids and channel_ids must be integer list, not commands')
|
||||
|
||||
# Find the message's author
|
||||
author_info = self._message_compute_author(author_id, email_from, raise_exception=True)
|
||||
author_id, email_from = author_info['author_id'], author_info['email_from']
|
||||
author_id, email_from = self._message_compute_author(author_id, email_from, raise_exception=True)
|
||||
|
||||
if not subtype_id:
|
||||
subtype = subtype or 'mt_note'
|
||||
@@ -1973,8 +1972,7 @@ class MailThread(models.AbstractModel):
|
||||
msg_kwargs = dict((key, val) for key, val in kwargs.items() if key in self.env['mail.message']._fields)
|
||||
notif_kwargs = dict((key, val) for key, val in kwargs.items() if key not in msg_kwargs)
|
||||
|
||||
author_info = self._message_compute_author(author_id, email_from, raise_exception=True)
|
||||
author_id, email_from = author_info['author_id'], author_info['email_from']
|
||||
author_id, email_from = self._message_compute_author(author_id, email_from, raise_exception=True)
|
||||
|
||||
if not partner_ids:
|
||||
_logger.warning('Message notify called without recipient_ids, skipping')
|
||||
@@ -2013,8 +2011,7 @@ class MailThread(models.AbstractModel):
|
||||
the log process. This method should be called within methods where
|
||||
access rights are already granted to avoid privilege escalation. """
|
||||
self.ensure_one()
|
||||
author_info = self._message_compute_author(author_id, email_from, raise_exception=False)
|
||||
author_id, email_from = author_info['author_id'], author_info['email_from']
|
||||
author_id, email_from = self._message_compute_author(author_id, email_from, raise_exception=False)
|
||||
|
||||
message_values = {
|
||||
'subject': subject,
|
||||
@@ -2038,8 +2035,7 @@ class MailThread(models.AbstractModel):
|
||||
|
||||
:param bodies: dict {record_id: body}
|
||||
"""
|
||||
author_info = self._message_compute_author(author_id, email_from, raise_exception=False)
|
||||
author_id, email_from = author_info['author_id'], author_info['email_from']
|
||||
author_id, email_from = self._message_compute_author(author_id, email_from, raise_exception=False)
|
||||
|
||||
base_message_values = {
|
||||
'subject': subject,
|
||||
@@ -2079,10 +2075,7 @@ class MailThread(models.AbstractModel):
|
||||
if not email_from and not self.env.su and raise_exception:
|
||||
raise exceptions.UserError(_("Unable to log message, please configure the sender's email address."))
|
||||
|
||||
return {
|
||||
'author_id': author_id,
|
||||
'email_from': email_from,
|
||||
}
|
||||
return author_id, email_from
|
||||
|
||||
def _message_create(self, values_list):
|
||||
if not isinstance(values_list, (list)):
|
||||
|
||||
Reference in New Issue
Block a user