From aece706603987b99008fd8e6fdfa0bd47f0e0bb8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Mon, 16 Nov 2015 14:00:07 +0100 Subject: [PATCH] [FIX] mail: incoming email parsing Correctly flag and remove nodes to remove containing odoo buttons. --- addons/mail/models/mail_thread.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/addons/mail/models/mail_thread.py b/addons/mail/models/mail_thread.py index 12345a32c27..fa6f2b0837f 100644 --- a/addons/mail/models/mail_thread.py +++ b/addons/mail/models/mail_thread.py @@ -1238,10 +1238,14 @@ class MailThread(models.AbstractModel): html_sanitize methods located in tools. """ root = lxml.html.fromstring(body) postprocessed = False + to_remove = [] for node in root.iter(): if 'o_mail_notification' in node.get('class', '') or 'o_mail_notification' in node.get('summary', ''): postprocessed = True - node.getparent().remove(node) + if node.getparent() is not None: + to_remove.append(node) + for node in to_remove: + node.getparent().remove(node) if postprocessed: body = etree.tostring(root, pretty_print=False, encoding='UTF-8') return body, attachments