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 ...
随机推荐
- KiFastCallEntry() 机制分析
1. 概述 从 windows xp 和 windows 2003 开始使用了快速切入内核的方式提供系统服务例程的调用. KiFastCallEntry() 的实现是直接使用汇编语言,C 语言不能直接 ...
- C盘清理垃圾
经常清理C盘垃圾,会让系统运行更快,避免死机,今天教大家一种简单实用的方法,用文本文档清理垃圾: 1:在电脑桌面空白处右键-建立文本文档: 2:把以下代码复制到文本里 @echo offecho 正在 ...
- ThreadPoolTaskExecutor的配置使用
版权声明:本文为博主原创文章,遵循CC 4.0 by-sa版权协议,转载请附上原文出处链接和本声明. 本文链接:https://blog.csdn.net/ft305977550/article/de ...
- Bootstrap 附加导航(Affix)插件
附加导航(Affix)插件允许指定 <div> 固定在页面的某个位置.一个常见的例子是社交图标.它们将在某个位置开始,但当页面点击某个标记,该 <div> 会锁定在某个位置,不 ...
- Android开发 SeekBar开发记录
前言 开发记录博客不是讲解使用博客,更多的是各种功能与点子的记录 基本使用 <SeekBar android:layout_width="match_parent" andr ...
- git 去除本地所有没有保存的修改
git 去除本地所有没有保存的修改,参考How do I revert all local changes in Git managed project to previous state? 知道运行 ...
- Cats Transport
Cats Transport 现在有n座山,第i座山的坐标为\(d_i\),初始p个饲养员在山1,有m只猫,每只猫有一个属性\(h_i,t_i\)表示猫i 在\(h_i\)以及它在\(t_i\)时间后 ...
- C++ BASS 实例
#include <iostream> #include <string> #include <map> #include "..\sdk\bass\in ...
- 概率dp——逆推期望+循环迭代zoj3329
首先要推出dp[i]的期望方程,会发现每一项都和dp[0]相关, 那我们将dp[i]设为和dp[0]有关的式子dp[i]=a[i]*dp[0]+b[i],然后再回代到原来的期望方程里 然后进行整理,可 ...
- Parse-轻松构建移动APP的后台服务
目前正在开发的产品告一段落,有时间总结下经验,也顺便分享一下我们主要使用的平台-Parse. 什么是Parse? Parse是一群美国人开发的专为移动APP服务的云计算平台,与现有的其他云计算平台相 ...