[FIX] core: do not translate html attributes without actual content

The issue has been introduced by 1fe4b0cc1981382cc3d944ec44276f0aee90945d.

A simple example is an element with attribute "string" like

    <field name="foo" string=" "/>

When the translation process is parsing the value of the attribute as
some HTML fragment html.from_string(" "), it raises an exception.  This
was not a problem before the commit above, but it now is.  For instance,
updating the view "event.view_event_form" triggers the error.

closes odoo/odoo#84144

X-original-commit: 5ffc1704162d8918985964b08f4b2b49e6054958
Signed-off-by: Raphael Collet <rco@odoo.com>
Signed-off-by: Christophe Simonis <chs@odoo.com>
This commit is contained in:
Christophe Simonis
2022-02-08 00:07:26 +00:00
committed by Raphael Collet
parent 43ccc78554
commit beb6a719bc
+1 -1
View File
@@ -260,7 +260,7 @@ def translate_xml_node(node, callback, parse, serialize):
# translate the attributes of the node
for key, val in node.attrib.items():
if val and key in TRANSLATED_ATTRS and TRANSLATED_ATTRS[key](node):
if nonspace(val) and key in TRANSLATED_ATTRS and TRANSLATED_ATTRS[key](node):
node.set(key, callback(val.strip()) or val)
process(node)