[FIX] mail: incoming email parsing

Correctly flag and remove nodes to remove containing odoo buttons.
This commit is contained in:
Thibault Delavallée
2015-11-17 10:51:03 +01:00
parent 6a93dd81fb
commit aece706603
+5 -1
View File
@@ -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