Omar
Omar

Reputation: 81

What is an external id and where we can use it in Odoo?

If anyone knows what an external id is, and what are its uses, I will be thankful.

I didn't find resources about that on the web.

Thanks in advance.

Upvotes: 3

Views: 6028

Answers (3)

m3asmi
m3asmi

Reputation: 1262

By debug mode then go the the form of the recod then view metadata from the Debug icon in the top left.
You can find it in the database by YOUR_MODEL and ID in the request:

select module,name
from ir_model_data
where model = 'YOUR_MODEL' and res_id=ID

Upvotes: 0

Daniel Reis
Daniel Reis

Reputation: 13382

An External ID, also known as an XML Id, is an identifier for a data record. Odoo uses a base Model, ir.model.data, to map identifiers with the corresponding actual database IDs.

Whenever an External Id is referenced by another data record, or by some server-side Python code, ir.model.data allows to translate that string identifier into the specific record ID used for it in this particular database.

Upvotes: 8

Jainik Patel
Jainik Patel

Reputation: 2324

get_external_id

is kinda crap and may not return an id: it just gets a random existing xid but won't generate one if there is no xid currently associated with the record. And operating with xids isn't exactly fun in RPC.

Example:

# backwards compatibility
get_xml_id = get_external_id
_get_xml_ids = _get_external_ids

Upvotes: 0

Related Questions