How it works...

An XML ID is a string that refers to a record in the database. The IDs themselves are records of the ir.model.data model. This model's rows contain the modules that declare the XML ID, the identifier string, the referred model, and the referred ID. Every time we write to an XML ID, Odoo checks whether the string is namespaced (that is, whether it contains exactly one dot), and, if not, it adds the current module name as a namespace. Then, it looks up whether there is already a record in ir.model.data with the specified name. If so, an UPDATE statement for the listed fields is executed; if not, a CREATE statement is executed. This is how you can provide partial data when a record already exists, as we did earlier.

A widespread application for partial data, apart from changing records defined by other modules, is using a shortcut element to create a record in a convenient way and writing a field on this record, which is not supported by the shortcut element:
<act_window id="my_action" name="My action" model="res.partner" />
<record id="my_action" model="ir.actions.act_window">
<field name="auto_search" eval="False" />
</record>

The ref function, as used in the Loading data using XML files recipe of this chapter, also adds the current module as a namespace if appropriate, but raises an error if the resulting XML ID does not exist already. This also applies to the id attribute if it is not namespaced already.

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

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