How to do it...

Create two XML files and link them in your __manifest__.py file:

  1. Add in a file called data/demo.xml to your manifest, in the demo section:
    'demo': [ 
        'data/demo.xml', 
    ],
  1. Add content to this file:
<odoo> 
    <record id="author_af" model="res.partner"> 
        <field name="name">Alexandre Fayolle</field> 
    </record> 
    <record id="author_dr" model="res.partner"> 
        <field name="name">Daniel Reis</field> 
    </record> 
    <record id="author_hb" model="res.partner"> 
        <field name="name">Holger Brunn</field> 
    </record> 
    <record id="book_cookbook" model="library.book"> 
        <field name="name">Odoo Cookbook</field> 
        <field name="short_name">cookbook</field> 
        <field name="date_release">2016-03-01</field> 
        <field name="author_ids"
eval="[(6, 0, [ref('author_af'), ref('author_dr'),
ref('author_hb')])]"
/> <field name="publisher_id" ref="res_partner_packt" /> </record> </odoo>
  1. Add a file called data/res_partner.xml to your manifest, in the data section:
    'data': [ 
        'data/res_partner.xml', 
    ], 
  1. Add content to this file:
<odoo> 
    <record id="res_partner_packt" model="res.partner"> 
        <field name="name">Packt Publishing</field> 
        <field name="city">Birmingham</field> 
        <field name="country_id" ref="base.uk" /> 
    </record> 
</odoo> 

When you update your module now, you'll see in any case the publisher we created, and if your database has demo data enabled, as pointed out in Chapter 2, Creating Odoo Modules, you'll also find this book and its authors.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.222.196.175