Reputation: 55600
The error message
"Element odoo has extra content: data"
may be generated if an xml file such as a view fails to validate against the RELAXNG schema file odoo/odoo/import_xml.rng
. Unforunately it isn't very specific. For example, this file:
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<record id="record_id" model="ir.ui.view">
<field name="name">foo.bar.form</field>
<field name="model">baz.model</field>
<field name="arch" type="xml">
<form string="My Form">
<sheet>
<group>
<field name="my_field"/>
</group>
</sheet>
</form>
</field>
</record>
<act_window id="action_quux" name="My Action" res_model="baz.model" view_model="form"/>
</data>
</odoo>
will generate the message when validated, but there is no indication that the specific problem is that view_model
should be view_mode
. Is there a way to get a better error message?
Upvotes: 2
Views: 629
Reputation: 55600
The error message, at least on Debian Linux, is produced by LXML's RelaxNG validator, which in turn relies on libxml2. We can see that xmllint, also based on libxml2
, produces the same output:
xmllint path/to/view.xml --relaxng ./odoo/odoo/import_xml.rng
<snip xml file content/>
path/to/view.xml:3: element data: Relax-NG validity error : Element odoo has extra content: data
path/to/view.xml fails to validate
We can't easily change how Odoo is validating XML files, but we can install a different validator, jing, and use that to validate our file in the terminal.
To install (on Debian-based systems):
$ sudo apt-get install jing libbatik-java libavalon-framework-java
Once installed, call it like this and review the more detailed error message (formatted for readability):
jing ./odoo/odoo/import_xml.rng path/to/view.xml
path/to/view.xml:23:9: error: attribute "view_model" not allowed here; expected attribute
"auto_refresh", "context", "domain", "groups", "key2", "limit", "multi", "src_model", "target", "usage",
"view_id", "view_mode" or "view_type"
Since Odoo 13, there is optional support for using the jingtrang package to generate jing's validation error messages in Odoo itself. To enable this support, install the jingtrang module from pypi.
Upvotes: 3