Search code examples
pythonxmlodooodoo-13

Unescaped '<' not allowed in attributes values


I am trying to add an XML attrs attribute that contains a < character:

<field name="discovery_note2" nolabel="1" placeholder="Note 2"
       attrs="{'invisible': ['|', ('is_discovery', '=', False), ('note_amount', '<', 0)]}"/>

But I am getting this error:

Error: XMLSyntaxError: Unescaped '<' not allowed in attributes values,

How can I pass the condition, if the note_amount field value is less than zero, then it should be invisible.

Note: note_amount is a computed field.


Solution

  • Escape < as &lt; in XML because an unescaped < is expected to be the start of markup.

    See also What characters do I need to escape in XML documents?