How can I find a record in database using its External Id?
Let's say I have the following record in my data file:
<record model="product.product" id="product_to_find"> ... </record>
How can I retrieve it in code-behind?
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
How can I find a record in database using its External Id?
Let's say I have the following record in my data file:
<record model="product.product" id="product_to_find"> ... </record>
How can I retrieve it in code-behind?
You can now do self.env.ref('external.identifier')
You retrieve it with a code like:
res_model, res_id = self.pool.get('ir.model.data').get_object_reference(cr, uid,'module','product_to_find')
product = self.pool.get(res_model).browse(cr, uid, res_id)
or using the new api
res_model, res_id = self.env['ir.model.data'].get_object_reference('module','product_to_find')
product = self.env[res_model].browse(res_id)
To complete this answeer... get_object(...) return immediately the record in new API. The same in old API is : xmlid_to_object(...)
Sure
Try to search it the same way searching the view id of a certain view
Create an account today to enjoy exclusive features and engage with our awesome community!
Üye Olİlgili Gönderiler | Cevaplar | Görünümler | Aktivite | |
---|---|---|---|---|
|
2
Oca 17
|
5860 | ||
|
2
Tem 17
|
15184 | ||
|
2
Kas 15
|
3927 | ||
|
0
Mar 25
|
831 | ||
|
0
Oca 25
|
2950 |