How to Load Demo Data in Odoo 18

Hi Odooers & Developers! 

Get started with this hands-on guide to Odoo! In this article, we'll learn how to load demo data in Odoo 18. Sometimes you need test data, like dummy employees or products, to try out your module and demonstrate how it works. This test data is called "demo data." I'll show you two easy ways to add demo data to your module: XML and CSV files.

As Odoo continues to evolve, the latest release, Odoo 18, introduces new features that make ERP implementation smoother and more powerful. For developers and integrators working with custom modules, loading demo data is for realistic testing, training, and showcasing functionalities. Demo data allows you to simulate a live application before real data is entered, which is crucial for development and client demos. This guide will walk you through loading demo data in Odoo 18 using XML and CSV files, linking them to your modules, and verifying their implementation.

 Let's learn step by step! 

What is Demo Data?

Demo data is sample (dummy) data. It helps you:

  • Test your module
  • Show how your module works.
  • Train users

Adding demo data to your Odoo module is a helpful way to test how your module works, train users, and show the features of your system. Demo data is like sample data (dummy records), making it easier to set up and understand your Odoo ERP system. You can add it using XML or CSV files. This data helps you customize Odoo for your business needs and manage your work more smoothly. Remember, demo data only loads if you check the "Load Demo Data" box when creating the database if you don't, Odoo won't include it.

Method 1: Load Demo Data Using XML

XML is good when your data has structure or relations.

Steps:

  1. In your custom module, make a new folder named demo.
  2. Inside that folder, create a file called demo_data.xml
  3. Add this code to the file:

demo_data.xml

XML

<?xml version="1.0" encoding="utf-8"?>

<odoo noupdate="1">
	<record id="1_dev_decoration_cake" model="decoration.cake">
     <field name="name">Black Forest Cake</field>
	</record>
	<record id="2_dev_decoration_cake" model="decoration.cake">
    	<field name="name">Layered Rainbow Cake</field>
	</record>
	<record id="3_dev_decoration_cake" model="decoration.cake">
    	<field name="name"> Traditional Fruitcake</field>
	</record>
	<record id="4_dev_decoration_cake" model="decoration.cake">
    	<field name="name">Double Chocolate Mousse Cake</field>
	</record>
	<record id="5_dev_decoration_cake" model="decoration.cake">
    	<field name="name">White Chocolate Cheesecake Wit</field>
	</record>
</odoo>

noupdate "1": This data will load only once, when the module is installed. It won't be updated or deleted later by Odoo updates.

1. Now, open your manifest.py file and add this:

.py

'demo': ['demo/demo_data.xml'],

Load demo data

Method 2: Load Demo Data Using CSV

CSV (Comma-Separated Values) is a simple text format where each line is a record, and commas separate fields. It's easy and great for bulk data!

Steps:

  1. Create a folder named data (if it doesn't exist yet)
  2. Inside the data folder, make a file named decoration.cake.csv
  3. Add this data to the CSV file:

CSV

id, name
1_dev_decoration_cake, Black Forest Cake
2_dev_decoration_cake , Layered Rainbow Cake
3_dev_decoration_cake , Traditional Fruitcake
4_dev_decoration_cake, Double Chocolate Mousse Cake
5_dev_decoration_cake, White Chocolate Cheesecake Wit

4. Then, in your manifest.py file, add this:

.py

'demo': ['data/decoration.cake.csv'],

5. Again, make sure "Load Demo Data" is checked when creating the database.

Load Demo Data

Now your demo data will be loaded automatically when you install your module.

Conclusion: 

In this tutorial, we have discussed two easy ways of importing demo data into Odoo. XML files work best for data with relationships, providing greater control over the data loading. CSV files, in contrast, work best for processing bulk data like lists of products and are easy to handle and process quickly.

To begin with, make sure you include demo files in the manifest.py under the 'demo' key and activate the "Load Demo Data" option during your Odoo database installation. However, note that XML is geared more towards structured data, and CSV is the best choice for bulk data. These approaches allow you to load demo data and improve testing and development for your Odoo installation.

At Devintellecs, we specialize in helping businesses maximize their Odoo implementations, ensuring smoother setups and better functionality for every module.


Odoo DEV 14 de mayo de 2025
Compartir
Archivar
Identificarse dejar un comentario
How to Create a Calendar View in Odoo 18