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视图

最新文章

  1. MySQL的Grant命令[转]
  2. github标记
  3. Proc-fs 编程
  4. SqlServer2008R2 修改表中列为自增列
  5. Linux 安装挂载时注意事项
  6. spark stream初探
  7. QQ浏览器不支持JS问题
  8. 关于webroot与web-inf
  9. Java网络编程:利用apache的HttpClient包进行http操作
  10. Java基础之数据类型和转换
  11. mysql常用基础操作语法(二)~~对表的增删改操作【命令行模式】
  12. [高级软件工程教学]团队Alpha阶段成绩汇总
  13. PyQT5 helloworld教程(转载)
  14. 类别不平衡问题和Softmax回归
  15. Java——静态变量/方法与实例变量/方法的区别
  16. mysql8.0.13免安装版配置
  17. SpringBoot之基础
  18. 格式化输出函数:printf 那些事 (C语言)
  19. [leetcode]Jump Game @ Python
  20. CentOS编绎gcc

热门文章

  1. iOS开发UIResponder简介API
  2. 剑指offer——18打印从1到最大的n位数
  3. js用document.getElementById时要注意!
  4. 记一次java简单的if语句使用多态重构
  5. 面向XX程序设计到底是个啥
  6. java 迷你DVD管理器
  7. SVN Cannot merge into a working copy that has local modifications
  8. springboot 简单搭建(thymeleaf 视图显示)
  9. PokerNet-poker recognition: 扑克识别 (6)
  10. 为什么串行传输时总是LSB在前?