Demo Data In Odoo

Data files (demo.xml)

Module data is declared via data files, XML files with <record> elements. Each <record> element creates or updates a database record.

<openerp>
    <data>

        <record model="{model name}" id="{record_identifier}">
            <field name="{a field name}">{avalue}</field>
        </record>

    </data>
<openerp>

   .model is the name of the Odoo model for the record

    id is an external identifier, it allows referring to the record (without having to know its in-database identifier)

    <field> elements have a name which is the name of the field in the model (e.g. description). Their body is the field's value.

Data files have to be declared in the manifest file to be loaded, they can be declared in the 'data' list (always loaded) or in the 'demo' list (only loaded in demonstration mode).

    # only loaded in demonstration mode
    'demo': [
        'demo.xml',
    ],

0 comments:

Copyright © 2013 SoftKul