Files
odoo_source/addons/portal/models/mail_message.py
T
Patrick Hoste 5cd1179329 [IMP] portal: add informative button to internal notes on portal chatter
PURPOSE

Before this commit, when the chatter was displayed on a portal page (with
the customer preview button) one could see the internal notes with a button
for toggling his visibility... which was ineffective because a portal user
could never see internal notes and on the opposite internal users could
always see them. This commit adds another informative (disabled) button for
internal notes.

SPECIFICATION

Adds a 'is_message_subtype_note' param on the message in the
_portal_message_format method.

LINKS

Task-2817892

closes odoo/odoo#89775

X-original-commit: 705af2c24e99b8f24482722cb4795c141330b1c6
Signed-off-by: Hoste Patrick (pko) <pko@odoo.com>
Signed-off-by: Warnon Aurélien (awa) <awa@odoo.com>
2022-04-27 07:52:25 +02:00

27 lines
1.2 KiB
Python

# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import models
class MailMessage(models.Model):
_inherit = 'mail.message'
def portal_message_format(self):
return self._portal_message_format([
'id', 'body', 'date', 'author_id', 'email_from', # base message fields
'message_type', 'subtype_id', 'is_internal', 'subject', # message specific
'model', 'res_id', 'record_name', # document related
])
def _portal_message_format(self, fields_list):
vals_list = self._message_format(fields_list)
message_subtype_note_id = self.env['ir.model.data']._xmlid_to_res_id('mail.mt_note')
IrAttachmentSudo = self.env['ir.attachment'].sudo()
for vals in vals_list:
vals['is_message_subtype_note'] = message_subtype_note_id and vals.get('subtype_id', [False])[0] == message_subtype_note_id
for attachment in vals.get('attachment_ids', []):
if not attachment.get('access_token'):
attachment['access_token'] = IrAttachmentSudo.browse(attachment['id']).generate_access_token()[0]
return vals_list