来自

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. [AIR] 新建窗口的方法

    有时根据需要,我们需要在AIR程序中开多个窗口window 以下新建一个窗口: var opion:NativeWindowInitOptions = new NativeWindowInitOpti ...

  2. linux内核调试技巧之addr2line

    addr2line工具是一个可以将指令的地址和可执行影像转换为文件名,函数名和源代码行数的工具.这在内核执行过程中出现崩溃时,可用于快速定位出出错的位置,进而找出代码的bug. 用法 addr2lin ...

  3. ArcGIS Engine渲染

    符号化之Renderer( 渲染)体系 ArcGIS Engine9.3对GIS数据的符号化分为矢量数据渲染和栅格数据渲染两大类.接下来分别介绍FeatureRender和RasterRender. ...

  4. git的基础介绍和使用

    git工作原理 git的工作原理还是比较简单的,当我们创建了本地代码仓库后,会在本地代码仓库的根目录中生成一个.git的隐藏文件. .git为一个文件目录,又叫做版本库.在本地代码仓库文件夹中,除.g ...

  5. WEB页面采集器编写经验之一:静态页面采集器

    严格意义来说,采集器和爬虫不是一回事:采集器是对特定结构的数据来源进行解析.结构化,将所需的数据从中提取出来:而爬虫的主要目标更多的是页面里的链接和页面的TITLE. 采集器也写过不少了,随便写一点经 ...

  6. MySQL MEM_ROOT详细讲解

    这篇文章会详细解说MySQL中使用非常广泛的MEM_ROOT的结构体,同时省去debug部分的信息,仅分析正常情况下,mysql中使用MEM_ROOT来做内存分配的部分. 在具体分析之前我们先例举在该 ...

  7. maven多项目配置实践

    工具:IntelliJ IDEA 1.新建maven项目top 略 提示:不使用任何模版 2.在上面的maven项目的目录下(虽然这不一定是必须的),新建另一个maven项目secend. 同上 3. ...

  8. EX的魔方

    https://www.luogu.org/problem/show?pid=2007 题目背景 常神牛从来没接触过魔方,所以他要借助计算机来玩.即使是这样,他还是很菜. 题目描述 常神牛家的魔方都是 ...

  9. java.lang.IllegalArgumentException: template not initialized; call afterPropertiesSet() before using

    在使用spring-data-redis时使用junit测试报错: java.lang.IllegalArgumentException: template not initialized; call ...

  10. python模块与包的导入

    1. 模块与包的区别 模块,即module,一个包含python语句的.py文件就是一个模块!每个源代码文件都会自动成为模块!没有额外的语法用来声明模块. 包,又称模块包,即module packag ...