odoo8 or openerp 通过xml id获取数据库id

来源:互联网 发布:如何编写js插件 编辑:程序博客网 时间:2024/05/21 00:16

How to get the Database Id from an XML 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

原创粉丝点击