[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 `<img/>` 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 `<img src="cid:..."/>` 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) <xbo@odoo.com>
Signed-off-by: Piryns Victor (pivi) <pivi@odoo.com>
This commit is contained in:
Victor Piryns (pivi)
2023-01-09 09:07:12 +01:00
parent 5bddc1eac9
commit 2753236aaa
+3 -1
View File
@@ -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):