1. 程式人生 > >odoo8 or openerp 通過xml id獲取資料庫id

odoo8 or openerp 通過xml id獲取資料庫id

The ir.model.data model also has a get_object() method returning a browsable record given a model name and an xml_id.
So, another solution could be:
m  = self.pool.get('ir.model.data')
id = m.get_object(cr, uid, 'base', 'user_root').id

get_object(cr, uid, module, xml_id)
module是路徑名字,xml_id就是 xml檔案中<record id='xxxx'/>中的id