From 2753236aaa0ec760cab15907fdba6b6df7af72ff Mon Sep 17 00:00:00 2001 From: "Victor Piryns (pivi)" Date: Tue, 20 Dec 2022 10:33:51 +0000 Subject: [PATCH] [FIX] project: display inline image from email in task description Current behaviour: When sending an email with an inlined image to an alias of a project, the image is broken in the task description. Expected behaviour: The image should be rendered correctly. Steps to reproduce: - Install Project - In Settings add a custom email server and set a domain alias - Create a new Project and in it's settings create an email alias - Send an email with an *inlined* image. (not attachment)\ - Image is not rendered correctly in the newly created task. Reason for the problem: Email with an embedded/inlined images are multipart, one is containing the base64 encoded image and has a `content-id`, another one is the html body that has an `` which source is a `cid` that references the `content-id` of the encoded image. When parsing the email when creating the task, we only take into account the `html` part of the email, which becomes the `message.body` which is used to fill in the description. Therefor we have an `` that references nothing. Fix: Use the already parsed and sanitized `message.body` from the message's thread, which converts the `content-ids` into relative links to web images. We fill with that the description's body. Affected versions: - saas-15.2 - saas-15.3 - 16.0 - master opw-3062444 closes odoo/odoo#109354 X-original-commit: 3c805400045f2ccc8ad4228eb5718af0e22a8027 Related: odoo/enterprise#35543 Signed-off-by: Xavier Bol (xbo) Signed-off-by: Piryns Victor (pivi) --- addons/project/models/project.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/addons/project/models/project.py b/addons/project/models/project.py index 96016ebe998..86dbccf369a 100644 --- a/addons/project/models/project.py +++ b/addons/project/models/project.py @@ -2418,7 +2418,6 @@ class Task(models.Model): 'name': msg.get('subject') or _("No Subject"), 'planned_hours': 0.0, 'partner_id': msg.get('author_id'), - 'description': msg.get('body'), } defaults.update(custom_values) @@ -2471,6 +2470,9 @@ class Task(models.Model): ('partner_id', '=', False), ('email_from', '=', new_partner.email), ('is_closed', '=', False)]).write({'partner_id': new_partner.id}) + # use the sanitized body of the email from the message thread to populate the task's description + if not self.description and message.subtype_id == self._creation_subtype() and self.partner_id == message.author_id: + self.description = message.body return super(Task, self)._message_post_after_hook(message, msg_vals) def action_assign_to_me(self):