From 5c2f96d0dde378fdb2736b2d67871954ab905434 Mon Sep 17 00:00:00 2001 From: len-odoo Date: Fri, 9 Nov 2018 11:53:51 +0000 Subject: [PATCH] [FIX] mail: create attachments on the correct record when using the popup editor Send a message using the popup editor. Drag and drop an image into the message content. It will create an attachment for the inlined image. However it did give a res_model value of mail.message but no res_id; add_missing_default_value would fill in the res_id from the _context, which is not the mail_message but the current object on which it applies (e.g. helpdesk.ticket). We put the correct res_model along with the res_id. opw 1903194 closes odoo/odoo#28526 --- addons/mail/models/mail_message.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/mail/models/mail_message.py b/addons/mail/models/mail_message.py index b5b94aaefb7..146ef168ed9 100644 --- a/addons/mail/models/mail_message.py +++ b/addons/mail/models/mail_message.py @@ -767,7 +767,8 @@ class Message(models.Model): 'name': name, 'datas': match.group(2), 'datas_fname': name, - 'res_model': 'mail.message', + 'res_model': values.get('model'), + 'res_id': values.get('res_id'), }) attachment.generate_access_token() values['attachment_ids'].append((4, attachment.id))