Enable Dark Mode!
how-data-file-loading-works-in-odoo-19.jpg
By: Ayana R

How Data File Loading Works in Odoo 19

Technical Odoo 19 Odoo Enterprises Odoo Community

Odoo is a highly data-driven platform. Almost everything in a module—views, menus, access rules, demo records, and even some logic—is defined through data files. In Odoo 19, this approach remains the same as earlier versions, relying mainly on XML and CSV files declared in a module’s __manifest__.py.

Knowing how these files are loaded and in what order is essential. Many installation and upgrade issues in Odoo come down to incorrect file sequencing or misuse of CSV vs XML.

Data Files in Odoo Modules

Data files are used to create records for models such as views, menus, access rights, and master data. Odoo supports two main formats:

  • Data file formats: Odoo supports XML for flexible and complex data, such as views, menus, groups, record rules, relational or conditional records, and data protected with noupdate="1", while CSV is used for simple, fast, tabular data like bulk imports and access control lists (ir.model.access.csv) that do not require complex logic.
  • By convention, files are organized into folders:

  • security/ – access rights, groups, record rules
  • data/ – master or configuration data
  • views/ – UI views and actions
  • demo/ – demo or sample data
{
    'name': 'Real Estate',
    'data': [
        'security/ir.model.access.csv',
        'views/estate_property_views.xml',
        'data/master_data.xml',
    ],
    'demo': [
        'demo/demo_data.xml',
    ],
}

CSV Files: When and How to Use Them

CSV files are best used when you need to load many simple records efficiently. They behave much like database tables, where the first row defines the fields.

Important points to remember:

  • Use field:id or :id to reference external IDs
  • CSV does not support expressions, conditions, or Python logic
  • For anything complex, XML is the better choice

Example: security/ir.model.access.csv

id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_estate_property_user,estate.property user,model_estate_property,base.group_user,1,1,1,0
access_estate_property_manager,estate.property manager,model_estate_property,estate.group_estate_manager,1,1,1,1

CSV files are loaded every time the module is installed or upgraded (-i or -u). Unlike XML, CSV does not support noupdate="1". If you need data that should load only once and remain untouched on upgrades, XML is the safer option.

Security Files: A Special Case

Security configuration in Odoo usually combines both XML and CSV:

  • Groups and record rules > XML
  • Access rights (ACLs) > CSV

This split exists mainly because ACLs are easier to manage in a tabular format.

One critical rule: security files depend on each other.

Access rights in ir.model.access.csv often reference groups that are defined in XML. Because of this, file order matters.

Correct order in __manifest__.py

'data': [
    'security/security.xml',          # Groups first
    'security/ir.model.access.csv',   # ACLs after
    # other files
],

If the CSV loads before the groups exist, Odoo will fail with errors like “Group not found”.

Loading Order: The Key to Avoiding Errors

Odoo loads data files sequentially in the exact order listed in the data (or demo) key of __manifest__.py.

This is essential because:

  • Later files can reference records created in earlier ones (via external IDs).
  • Dependencies must resolve in order (e.g., countries before states, groups before access rights).

From Odoo 19 documentation: "The data files are sequentially loaded following their order in the manifest.py file. This means that if data A refers to data B, you must make sure that B is loaded before A".

Data loads only on module installation (-i) or upgrade (-u). Demo data loads only if the --demo flag is used or enabled during database creation.

Noupdate and Demo Data

XML and noupdate

XML allows you to protect records from being overwritten during upgrades:

<data noupdate="1">
    <record id="example_record" model="res.partner">
        ...
    </record>
</data>

This is useful for the default configuration that users might later modify.

CSV Limitation

CSV files do not support noupdate. Any CSV record will be re-applied on every upgrade.

Demo Data

Demo data is meant for testing and demonstrations. It is optional and typically uses noupdate="1" so it does not interfere with real data.

Mastering data file loading in Odoo 19 prevents common pitfalls like reference errors or overwritten customizations. Prioritize correct ordering in __manifest__.py, use CSV judiciously for simple bulk data (especially security ACLs), and leverage XML for flexibility and noupdate control.

To read more about An Overview of Data Files Core Operations in Odoo 18, refer to our blog An Overview of Data Files Core Operations in Odoo 18.


If you need any assistance in odoo, we are online, please chat with us.



0
Comments



Leave a comment



Recent Posts

whatsapp_icon
location

Calicut

Cybrosys Technologies Pvt. Ltd.
Neospace, Kinfra Techno Park
Kakkancherry, Calicut
Kerala, India - 673635

location

Kochi

Cybrosys Technologies Pvt. Ltd.
1st Floor, Thapasya Building,
Infopark, Kakkanad,
Kochi, India - 682030.

location

Bangalore

Cybrosys Techno Solutions
The Estate, 8th Floor,
Dickenson Road,
Bangalore, India - 560042

Send Us A Message