[FIX] base_search_mail_content: Don't fail on views with searchpanel

On views with a searchpanel, xpath `//field[last()]` may select an element inside
the search panel, provoking the error "Only types ['many2one'] are supported for
category (found type text)".

This fix uses an stricter xpath for avoiding this situation.

TT25796
pull/623/head
Pedro M. Baeza 2020-10-06 12:29:14 +02:00
parent 7d46924b29
commit c0e0964880
1 changed files with 1 additions and 2 deletions

View File

@ -50,8 +50,7 @@ class MailThread(models.AbstractModel):
res["fields"].update(
{"message_content": {"type": "char", "string": _("Message Content")}}
)
for node in doc.xpath("//field[last()]"):
for node in doc.xpath("/search/field[last()]"):
# Add message_content in search view
elem = etree.Element("field", {"name": "message_content"})
node.addnext(elem)