来自

Odoo Web服务暴露出相关的服务,路由分别是

  1. /xmlrpc/
  2. /xmlrpc/2/
  3. /jsonrpc

根据 services 调用 后端对应服务的 方法method 【定义 openerp\http.py 之 dispatch_rpc()】,然后再将结果从python dict 转换为 xml-rpc 格式 或者 json-rpc 返回

   service 对应的后端服务分别是

  1. common, openerp.service.common
  2. db,openerp.service.db
  3. object , openerp.service.model
  4. report, openerp.service.report

各服务提供的方法如下

service

method

说明

common

login

authenticate

version

about

set_loglevel

db

create_database

duplicate_database

drop

dump

restore

rename

change_admin_password

migrate_database

db_exist

list

list_lang

list_countries

server_version

object

execute

execute_kw

execute_workflow

report

report

report_get

render_report

实现自己的方法时,要按照约定,以 'exp_' 开头。

XML-RPC接口调用

#在 note.note 模型创建新纪录

import xmlrpclib

root = 'http://%s:%d/xmlrpc/' % (HOST, PORT)

uid = xmlrpclib.ServerProxy(root + 'common').login(DB, USER, PASS) # common是服务,login 是方法

print "Logged in as %s (uid: %d)" % (USER, uid)

# Create a new note

sock = xmlrpclib.ServerProxy(root + 'object')

args = {

'color' : 8,

'memo' : 'This is a note',

'create_uid': uid,

}

note_id = sock.execute(DB, uid, PASS, 'note.note', 'create', args) #调用服务'object'的方法 execute(),传入的参数为 (DB, uid, PASS, 'note.note', 'create', args)

JSON-RPC接口调用

#在 note.note 模型创建新纪录

import jsonrpclib

# server proxy object

url = "http://%s:%s/jsonrpc" % (HOST, PORT)

server = jsonrpclib.Server(url)

# log in the given database

uid = server.call(service="common", method="login", args=[DB, USER, PASS]) #调用服务'common'的方法 login()

# helper function for invoking model methods

def invoke(model, method, *args):

args = [DB, uid, PASS, model, method] + list(args)

return server.call(service="object", method="execute", args=args) #调用服务'object'的方法 execute()

# create a new note

args = {

'color' : 8,

'memo' : 'This is another note',

'create_uid': uid,

}

note_id = invoke('note.note', 'create', args) #传入参数

其他

同时odoo Web 还为 odoo web client 提供了 大量的 json-rpc接口。例如数据集提供的服务如下, 定义在 class DataSet(http.Controller) [ addons\web\controllers\main.py ]。

routing

说明

/web/dataset/search_read

/web/dataset/load

/web/dataset/call

/web/dataset/call_kw

/web/dataset/call_buttion

/web/dataset/exec_workflow

/web/dataset/resequence

webclient 在调用 工作流时,直接 调用 rpc服务

/**

* Executes a signal on the designated workflow, on the bound OpenERP model

*

* @param {Number} id workflow identifier

* @param {String} signal signal to trigger on the workflow

*/

exec_workflow: function (id, signal) {

return session.rpc('/web/dataset/exec_workflow', {

model: this.name,

id: id,

signal: signal

});

},

转载注明原作者 /by Jeffery

Odoo Web Service API的更多相关文章

  1. 【完全开源】百度地图Web service API C#.NET版,带地图显示控件、导航控件、POI查找控件

    目录 概述 功能 如何使用 参考帮助 概述 源代码主要包含三个项目,BMap.NET.BMap.NET.WindowsForm以及BMap.NET.WinformDemo. BMap.NET 对百度地 ...

  2. 【转】【完全开源】百度地图Web service API C#.NET版,带地图显示控件、导航控件、POI查找控件

    [转][完全开源]百度地图Web service API C#.NET版,带地图显示控件.导航控件.POI查找控件 目录 概述 功能 如何使用 参考帮助 概述 源代码主要包含三个项目,BMap.NET ...

  3. VMware 虚拟化编程(3) —VMware vSphere Web Service API 解析

    目录 目录 前文列表 VMware vSphere Web Services API VMware vSphere Web Services SDK vSphere WS API 中的托管对象 Man ...

  4. 使用Web Service进行网络编程-----Web Service简介

    Android应用通常都是运行在手机平台上,手机系统的硬件资源是有限的,不管是存储能力还是计算能力都是有限的,在Android系统上开发.运行一些单用户.小型应用是可能的,但对于需要进行大量的数据处理 ...

  5. REST和SOAP Web Service的区别比较

    本文转载自他人的博客,ArcGIS Server 推出了 对 SOAP 和 REST两种接口(用接口类型也许并不准确)类型的支持,本文非常清晰的比较了SOAP和Rest的区别联系! ///////// ...

  6. 微软BI 之SSIS 系列 - 在 SSIS 中使用 Web Service 以及 XML 解析

    开篇介绍 Web Service 的用途非常广几乎无处不在,像各大门户网站上的天气预报使用到的第三方 Web Service API,像手机客户端和服务器端的交互等都可以通过事先设计好的 Web Se ...

  7. WCF、Web API、WCF REST、Web Service比较

    原文地址:http://www.dotnet-tricks.com/Tutorial/webapi/JI2X050413-Difference-between-WCF-and-Web-API-and- ...

  8. Difference between WCF and Web API and WCF REST and Web Service

    The .Net framework has a number of technologies that allow you to create HTTP services such as Web S ...

  9. WCF 、Web API 、 WCF REST 和 Web Service 的区别

    WCF .Web API . WCF REST 和 Web Service 的区别 The .Net framework has a number of technologies that allow ...

随机推荐

  1. Visual Studio 设置多核编译

    1.选择一个指定项目右击 -> 属性 -> 配置属性 -> C/C++ -> 命令行 在附加选项中输入:/MP4 或者/MP8 等,后面的那个数字是指定CPU 核的数量,可以自 ...

  2. bootstrap下使用模态框,在模态框内输入框中回车时,模态框自动关闭的问题及解决方法

    使用bootstrap下模态框,构建表单提交页面,但是输入框中直接回车,本来是想执行一下验证,但是却导致模态框自动关闭了. 遇到这样的问题,只需要先禁止回车触发表单提交            $(do ...

  3. 查询sql2005&2008全部表信息

    如果是查询sql server ,把sys.extended_properties修改为SysProperties SELECT 表名 THEN D.NAME ELSE '' END, 表说明 THE ...

  4. Java Docs

    1 Java Docs on Oracle:   1.1 Online(EN): JavaSE6  http://docs.oracle.com/javase/6/docs/api/index.htm ...

  5. 数据库使用--MyISAM InnoDB 区别

    MyISAM 和 InnoDB 讲解 InnoDB和MyISAM是许多人在使用MySQL时最常用的两个表类型,这两个表类型各有优劣,视具体应用而定.基本的差别为:MyISAM类型不支持事务处理等高级处 ...

  6. oracle加并行参数PARALLEL

    select /*+ PARALLEL(t,4) */ * from table1

  7. iOS静态分析举例

    XCode-> Product -> Analyze 即可进行iOS静态代码分析.静态分析能发现的问题包括以下几种类型: 1.逻辑错误:访问空指针或未初始化的变量等: 2.内存管理错误:如 ...

  8. android微信分享要注意的地方

    最近在做android端分享的功能,在微信开放平台查看了下官网上的开发文档,一步一步的按文档上的步骤来: 1.申请你的AppID 2.下载开发工具包 3.搭建开发环境,引入libammsdk.jar文 ...

  9. C语言dsPIC / PIC24 serial bootloader和C#语言bootloader PC端串口通信程序

    了解更多关于bootloader 的C语言实现,请加我QQ: 1273623966 (验证信息请填 bootloader),欢迎咨询或定制bootloader(在线升级程序). 新dsPIC/PIC2 ...

  10. Word自动生成目录

    博主最近在写报告的时候要在Word里面做个目录,再做个页码,然后上网搜了一些方法,非常零散,我弄了好久才弄好.在这里我把整套方法分享一下. 声明:内容完全独创! 工具:Word 2016. 效果:如下 ...