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:
Add a data file to your module manifest:
'data': [ 'data/res_partner.xml', ],
Change the name of our main company:
<record id="base.main_company" model="res.company"> <field name="name">Packt publishing</field> </record>
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...