summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThibault Delavallée <tde@odoo.com>2019-11-29 10:31:52 +0000
committerThibault Delavallée <tde@odoo.com>2019-11-29 13:35:14 +0000
commit351b0ca6f4f493fed3542c8f52e8ec70ee622b7e (patch)
tree785c040363d3886d4084dc2d327e7d7431995689
parent9b3de324783fc0a2305237756328f6a141c8ee6e (diff)
[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
-rw-r--r--addons/mail/models/mail_thread.py17
1 files changed, 5 insertions, 12 deletions
diff --git a/addons/mail/models/mail_thread.py b/addons/mail/models/mail_thread.py
index ac7442fa13e..0c53cbad6b1 100644
--- a/addons/mail/models/mail_thread.py
+++ b/addons/mail/models/mail_thread.py
@@ -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)):