Sometimes, we need demo data to be loaded when we upgrade the module for the first time.

In this case, we have to create entries in xml.

Consider a module:

Import models

# -*- coding: utf-8 -*-


‘name’: “mymodule”,

‘author’: “My Company”,

‘website’: ““,

‘category’: ‘Uncategorized’,

‘version’: ‘0.1’,

‘depends’: [‘base’],

‘data’: [


   ‘demo’: [

          ‘demo.xml’, # file with demo data



from openerp import models, fields, api

class my_module(models.Model):

_name = ‘my.module’

name = fields.Char()

value = fields.Integer()

value2 = fields.Float(compute=”_value_pc”, store=True)

description = fields.Text()


def _value_pc(self):

self.value2 = float(self.value) / 100



<?xml version=”1.0″ encoding=”utf-8″?>



<record model=”ir.ui.view” id=”my_module_list”>

<field name=”name”>my_module list</field>

<field name=”model”>my.module</field>

<field name=”arch” type=”xml”>


<field name=”name”/>

<field name=”value”/>

<field name=”value2″/>




<record model=”ir.ui.view” id=”my_module_form”>

<field name=”name”>my_module Form</field>

<field name=”model”>my.module</field>

<field name=”arch” type=”xml”>

<form string=”My Module”>

<field name=”name”/>

<field name=”value”/>

<field name=”value2″/>




<record model=”ir.actions.act_window” id=”action_my_module_id”>

<field name=”name”>my_module</field>

<field name=”res_model”>my.module</field>

<field name=”view_mode”>tree,form</field>


<menuitem name=”my_module” id=”menu_root”/>

<menuitem name=”Menu 1″ id=”my_module_menu_1″ parent=”menu_root” action=”action_my_module_id”/>



This is demo.xml which will have demo data loaded into it  Wherein Field name refers to Column name (In this example it is name,value)


<data noupdate=”1″>

<record id=”object0″ model=”my.module”>

<field name=”name”>Object 0</field>

<field name=”value”>0</field>


<record id=”object1″ model=”my.module”>

<field name=”name”>Object 1</field>

<field name=”value”>10</field>


<record id=”object2″ model=”my.module”>

<field name=”name”>Object 2</field>

<field name=”value”>20</field>




This demo data is loaded as soon as module is upgraded for the first time. Visit to know further details.

Watch our videos on YouTube.