In Odoo 19, XML remains a cornerstone of backend development. Whether you are defining default configuration, initializing records, managing security, or wiring modules together, XML data files provide a declarative, reliable way to structure and load information into the Odoo ORM.
This guide is written for developers who want a clear, practical, and complete understanding of XML data in Odoo 19, from fundamentals to real-world best practices.
What Is XML Data?
XML data in Odoo refers to structured files used to create or update database records at module installation or upgrade time.
Unlike Python scripts that execute logic, XML data is declarative, you define what the data should look like, and Odoo handles how it’s stored.
Key Characteristics
- Loaded automatically by the module system
- Integrated with the ORM
- Uses external IDs (XML IDs) for long-term reference
- Supports upgrades and inheritance
Structure of an XML Data File in Odoo 19
Every XML data file starts with a declaration and an <odoo> root element:
<?xml version="1.0" encoding="UTF-8"?>
<odoo>
<data>
</data>
</odoo>
1. The <data> tag contains all records and optional attributes such as noupdate.
2. The <record> element defines a single database record.
<record id="your_id" model="model.name">
<field name="field_name">value</field>
</record>
3. The <field> Element
Fields define the actual data stored in the record.
<field name="active">True</field>
<field name="sequence">10</field>
Referencing Other Records
<field name="user_id" ref="base.user_admin"/>
Loading XML Data in Odoo 19 Modules
Declaring XML Files in __manifest__.py
'data': [
'data/your_data_file.xml',
],
Load Order Matters
- Files load top to bottom
- Dependencies must be loaded first
- Security data should load early
Updating and Overriding XML Data in Odoo 19
Understanding noupdate="1"
<data noupdate="1">
- Prevents record updates during module upgrades
- Ideal for user-modifiable configuration
Overriding Existing Records
To override an existing record, reuse its XML ID in another module with the same model.
Conclusion
XML data files are fundamental to professional Odoo 19 development. When used correctly, they ensure clean installations, predictable upgrades, and maintainable modules. Mastering XML data is not optional it’s a core skill for every Odoo developer.
