Closed function2000 closed 2 years ago
Hi!
You can post message with attachment in two rpc calls.
Mail message model has a hint how multiple attachments are linked to document and message. See https://github.com/odoo/odoo/blob/084d06a5892ab2723d02dc29f0e62377c554efac/addons/mail/models/mail_message.py#L45-L50
For instance, if you need to post message on sales order and you already know sale order's id
:
{
'name': 'attachment.jpg',
'datas': base64Encode(attachmentData),
'type': 'binary',
'description': 'attachment.jpg',
'res_model': 'sale.order',
'res_id': saleOrderId
}
id
you can pass it to message_post
as attachment_ids
param wrapped in a list.Hi!
You can post message with attachment in two rpc calls.
Mail message model has a hint how multiple attachments are linked to document and message. See https://github.com/odoo/odoo/blob/084d06a5892ab2723d02dc29f0e62377c554efac/addons/mail/models/mail_message.py#L45-L50
For instance, if you need to post message on sales order and you already know sale order's
id
:
- Create attachment with following fields.
{ 'name': 'attachment.jpg', 'datas': base64Encode(attachmentData), 'type': 'binary', 'description': 'attachment.jpg', 'res_model': 'sale.order', 'res_id': saleOrderId }
- After you got attachment
id
you can pass it tomessage_post
asattachment_ids
param wrapped in a list.
Thank you very much! I will check then.
Can you please guide how to post with attachment like picture? For example call method "message_post" with attachment picture. A detail example is appreciated.