Book Image

Odoo Development Cookbook

By : Holger Brunn, Alexandre Fayolle, Daniel Reis
Book Image

Odoo Development Cookbook

By: Holger Brunn, Alexandre Fayolle, Daniel Reis

Overview of this book

Odoo is a full-featured open source ERP with a focus on extensibility. The flexibility and sustainability of open source is also a key selling point of Odoo. It is built on a powerful framework for rapid application development, both for back-end applications and front-end websites. The book starts by covering Odoo installation and administration, and provides a gentle introduction to application development. It then dives deep into several of the areas that an experienced developer will need to use. You’ll learn implement business logic, adapt the UI, and extend existing features.
Table of Contents (23 chapters)
Odoo Development Cookbook
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

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 to our partner. On subsequent updates of our module, only the publisher will be assigned, but the company's name will be left untouched.

How it works...

An XML ID is a string referring...