odoo 下 get_object_reference 函数
get_object_reference是 ir.model.data 模块中下的一个函数
该函数通过调用ir.model.data 模块中另外一个函数 xmlid_lookup 返回结果
def get_object_reference(self, cr, uid, module, xml_id):
"""Returns (model, res_id) corresponding to a given module and xml_id (cached) or raise ValueError if not found"""
return self.xmlid_lookup(cr, uid, "%s.%s" % (module, xml_id))[1:3]
# NEW V8 API
@tools.ormcache(skiparg=3)
def xmlid_lookup(self, cr, uid, xmlid):
"""Low level xmlid lookup
Return (id, res_model, res_id) or raise ValueError if not found
"""
module, name = xmlid.split('.', 1)
ids = self.search(cr, uid, [('module','=',module), ('name','=', name)])
if not ids:
raise ValueError('External ID not found in the system: %s' % (xmlid))
# the sql constraints ensure us we have only one result
res = self.read(cr, uid, ids[0], ['model', 'res_id'])
if not res['res_id']:
raise ValueError('External ID not found in the system: %s' % (xmlid))
return ids[0], res['model'], res['res_id']
返回的是 xml 视图id model res_id
实例:
@api.multi
def popup_wizard( self ):
if self._context is None:
self._context = {}
ir_model_data = self.env['ir.model.data']
try:
compose_form_id = ir_model_data.get_object_reference( 'ir_export_extended_ept', 'export_wizard_view_ept' )[1]
except ValueError:
compose_form_id = False
return {
'name': _( 'Export File' ),
'res_model': 'export.wizard.ept',
'type': 'ir.actions.act_window',
'view_id': compose_form_id,
'view_mode': 'form',
'view_type': 'form',
'target': 'new',
}
在odoo里有很多类似例子,用它来返回一个form视图
odoo 下 get_object_reference 函数的更多相关文章
- linux和window下mkdir函数问题(转-锦曦月)
通过WIN32宏进行判断 window下mkdir函数 #include<direct.h> int _mkdir( const char *dirname ); linux下 ...
- linux下syscall函数,SYS_gettid,SYS_tgkill
出处:http://blog.chinaunix.net/uid-28458801-id-4630215.html linux下syscall函数,SYS_gettid,SYS_tgkill ...
- hdwiki model目录下的函数类
model目录下的函数类 actions.class.php(站内地图相关) getHTML:获得页面菜单和相关信息 getMap:生成站内地图 adv.class.php 对wiki_adve ...
- 对于linux下system()函数的深度理解(整理)
原谅: http://blog.sina.com.cn/s/blog_8043547601017qk0.html 这几天调程序(嵌入式linux),发现程序有时就莫名其妙的死掉,每次都定位在程序中不同 ...
- windows 下实现函数打桩:拦截API方式
windows 下实现函数打桩:拦截API方式 近期由于工作须要,開始研究函数打桩的方法. 由于不想对project做过多的改动,于是放弃了使用Google gmock的想法. ...
- Linux下c函数dlopen实现加载动态库so文件代码举例
dlopen()是一个强大的库函数.该函数将打开一个新库,并把它装入内存.该函数主要用来加载库中的符号,这些符号在编译的时候是不知道的.这种机制使得在系统中添加或者删除一个模块时,都不需要重新编译了. ...
- linux和window下mkdir函数
通过WIN32宏进行判断 window下mkdir函数 #include<direct.h> int _mkdir( const char *dirname ); linux下 ...
- 转:对于linux下system()函数的深度理解(整理)
这几天调程序(嵌入式linux),发现程序有时就莫名其妙的死掉,每次都定位在程序中不同的system()函数,直接在shell下输入system()函数中调用的命令也都一切正常.就没理这个bug,以为 ...
- 【C/C++】Linux下system()函数引发的错误
http://my.oschina.net/renhc/blog/54582 [C/C++]Linux下system()函数引发的错误 恋恋美食 恋恋美食 发布时间: 2012/04/21 11:3 ...
随机推荐
- 秦曾昌人工智能课程---6、Decision Tree Learning
秦曾昌人工智能课程---6.Decision Tree Learning 一.总结 一句话总结: 怎样去构建决策树:比如一维:***|00|***|000|***,|为分割线,每个分割点都是一种情况, ...
- mysql 第一次启动及常用命令
启动 mysql -u root -p 进入后 # 显示有几个数据库 mysql> show databases; +--------------------+ | Database | +-- ...
- ubantu 编译mysql++
sudo apt-get install mysql-server mysql-client 指定mysql-lib位置: ./configure --with-mysql-lib=/usr/lib/ ...
- CometOJ Contest #3 C
题目链接:https://cometoj.com/contest/38/problem/C?problem_id=1542&myself=0&result=0&page=1&a ...
- 引入css文件时,css link和@import区别
这里link与@import介绍的是html引入css的语法单词.两者均是引入css到html的单词. 一.了解基本 1.link语法结构 <link href="CSSurl路径&q ...
- 6-Python操作MySQL-增(insert)-删(delete)-改(update)-查(select)
增删改 from pymysql import * def main(): # 创建Connection连接 conn = connect(host='localhost',port=3306,dat ...
- jQuery post使用变量作参数名
jQuery Query Post使用方法: $.post("test.php", { name: "John", time: "2pm" ...
- HduOJ 2162 - Primes
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2161 题意:判断n是不是素数,输入到0停止.题目规定1 2 都不是素数. 题解:筛素数.老题目.不过这 ...
- JQuery ajax提交表单及表单验证
JQuery ajax提交表单及表单验证 博客分类: jsp/html/javascript/ajax/development Kit 开源项目 注:经过验证,formValidator只适合一个 ...
- luoguP1890 gcd区间 [st表][gcd]
题目描述 给定一行n个正整数a[1]..a[n]. m次询问,每次询问给定一个区间[L,R],输出a[L]..a[R]的最大公因数. 输入输出格式 输入格式: 第一行两个整数n,m. 第二行n个整数表 ...