O'Reilly logo

Odoo Development Cookbook by Daniel Reis, Alexandre Fayolle, Holger Brunn

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Using external IDs and namespaces

There was a lot of talk about XML IDs already, without specifying what an XML ID is. This recipe will give a deeper understanding of this.

How to do it...

We write into already existing records to demonstrate how to use cross module references:

  1. Add a data file to your module manifest:
        'data': [
            'data/res_partner.xml',
        ],
  2. Change the name of our main company:
    <record id="base.main_company" model="res.company">
        <field name="name">Packt publishing</field>
    </record>
  3. Set our main company's partner as publisher:
    <record id="book_cookbook" model="library.book">
        <field name="publisher_id" ref="base.main_partner" />
    </record>

On installation of this module, the company will be renamed and the book from the next recipe will be assigned ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required