From 20d6c0c7e2ee9564e97ab3a970ce7d8518b46e58 Mon Sep 17 00:00:00 2001 From: Jeremy Kersten Date: Wed, 22 Sep 2021 09:58:07 +0000 Subject: [PATCH] [FIX] website: dynamic snippet, use lxml.html to process rendered view MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit t-field of a Text field, will use nl2br function that replace \n to
. So it is html that we need to parse. Add one return line in your sale description, and the rendering will fail with an error opening and ending missmatch for br... closes odoo/odoo#77108 X-original-commit: 3b3f9b24362e57b4c1538d8377ef4de5f3d65058 Signed-off-by: Jérémy Kersten (jke) --- addons/website/models/website_snippet_filter.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/addons/website/models/website_snippet_filter.py b/addons/website/models/website_snippet_filter.py index e2266fdf558..b8041f398e3 100644 --- a/addons/website/models/website_snippet_filter.py +++ b/addons/website/models/website_snippet_filter.py @@ -5,8 +5,7 @@ from collections import OrderedDict from odoo import models, fields, api, _ from odoo.exceptions import ValidationError, MissingError from odoo.osv import expression -from odoo.tools import html_escape as escape -from lxml import etree as ET +from lxml import etree, html import logging from random import randint @@ -77,7 +76,7 @@ class WebsiteSnippetFilter(models.Model): records=records, is_sample=is_sample, )) - return [ET.tostring(el, encoding='unicode') for el in ET.fromstring('%s' % str(content)).getchildren()] + return [etree.tostring(el, encoding='unicode') for el in html.fromstring('%s' % str(content)).getchildren()] def _prepare_values(self, limit=None, search_domain=None): """Gets the data and returns it the right format for render."""