[REM] mail: remove 'legacy' support in message_format
'legacy' parameter was present only for a specific part of attachments formatting. It was used only for portal, as the widget used in frontend was not using the 'discuss' orm-like convention. As portal formatting is now independent from mail/discuss formatting this can be safely removed, simplifying the API. Task-3322905 Part-of: odoo/odoo#121104
This commit is contained in:
@@ -7,7 +7,7 @@ from odoo import models
|
||||
class MailMessage(models.Model):
|
||||
_inherit = 'mail.message'
|
||||
|
||||
def _message_format(self, fnames, format_reply=True, legacy=False):
|
||||
def _message_format(self, fnames, format_reply=True):
|
||||
"""Override to remove email_from and to return the livechat username if applicable.
|
||||
A third param is added to the author_id tuple in this case to be able to differentiate it
|
||||
from the normal name in client code.
|
||||
@@ -17,7 +17,7 @@ class MailMessage(models.Model):
|
||||
This allows the frontend display to include the additional features
|
||||
(e.g: Show additional buttons with the available answers for this step). """
|
||||
|
||||
vals_list = super()._message_format(fnames=fnames, format_reply=format_reply, legacy=legacy)
|
||||
vals_list = super()._message_format(fnames=fnames, format_reply=format_reply)
|
||||
for vals in vals_list:
|
||||
message_sudo = self.browse(vals['id']).sudo().with_prefetch(self.ids)
|
||||
discuss_channel = self.env['discuss.channel'].browse(message_sudo.res_id) if message_sudo.model == 'discuss.channel' else self.env['discuss.channel']
|
||||
|
||||
@@ -50,29 +50,22 @@ class IrAttachment(models.Model):
|
||||
self.ensure_one()
|
||||
return self.env.user.partner_id
|
||||
|
||||
def _attachment_format(self, legacy=False):
|
||||
def _attachment_format(self):
|
||||
safari = request and request.httprequest.user_agent and request.httprequest.user_agent.browser == 'safari'
|
||||
res_list = []
|
||||
for attachment in self:
|
||||
res = {
|
||||
return [
|
||||
{
|
||||
'checksum': attachment.checksum,
|
||||
'id': attachment.id,
|
||||
'filename': attachment.name,
|
||||
'name': attachment.name,
|
||||
'mimetype': 'application/octet-stream' if safari and attachment.mimetype and 'video' in attachment.mimetype else attachment.mimetype,
|
||||
}
|
||||
if not legacy:
|
||||
res['originThread'] = [('insert', {
|
||||
'originThread': [('insert', {
|
||||
'id': attachment.res_id,
|
||||
'model': attachment.res_model,
|
||||
})]
|
||||
else:
|
||||
res.update({
|
||||
'res_id': attachment.res_id,
|
||||
'res_model': attachment.res_model,
|
||||
})
|
||||
res_list.append(res)
|
||||
return res_list
|
||||
})],
|
||||
}
|
||||
for attachment in self
|
||||
]
|
||||
|
||||
@api.model
|
||||
def _get_upload_env(self, request, thread_model, thread_id):
|
||||
|
||||
@@ -866,7 +866,7 @@ class Message(models.Model):
|
||||
# MESSAGE READ / FETCH / FAILURE API
|
||||
# ------------------------------------------------------
|
||||
|
||||
def _message_format(self, fnames, format_reply=True, legacy=False):
|
||||
def _message_format(self, fnames, format_reply=True):
|
||||
"""Reads values from messages and formats them for the web client."""
|
||||
vals_list = self._read_format(fnames)
|
||||
thread_ids_by_model_name = defaultdict(set)
|
||||
@@ -908,7 +908,7 @@ class Message(models.Model):
|
||||
'default_subject': default_subject,
|
||||
'guestAuthor': guestAuthor,
|
||||
'notifications': message_sudo.notification_ids._filtered_for_web_client()._notification_format(),
|
||||
'attachment_ids': message_sudo.attachment_ids._attachment_format() if not legacy else message_sudo.attachment_ids._attachment_format(legacy=True),
|
||||
'attachment_ids': message_sudo.attachment_ids._attachment_format(),
|
||||
'trackingValues': allowed_tracking_ids._tracking_value_format(),
|
||||
'linkPreviews': message_sudo.link_preview_ids._link_preview_format(),
|
||||
'messageReactionGroups': reaction_groups,
|
||||
|
||||
Reference in New Issue
Block a user