Welcome, guest | Sign In | My Account | Store | Cart

Notice! PyPM is being replaced with the ActiveState Platform, which enhances PyPM’s build and deploy capabilities. Create your free Platform account to download ActivePython or customize Python with the packages you require and get automatic updates.

Download
ActivePython
INSTALL>
pypm install openerp-client-lib

How to install openerp-client-lib

  1. Download and install ActivePython
  2. Open Command Prompt
  3. Type pypm install openerp-client-lib
 Python 2.7Python 3.2Python 3.3
Windows (32-bit)
1.0.3
1.1.2Never BuiltWhy not?
1.0.3 Available View build log
1.0.0 Available View build log
Windows (64-bit)
1.0.3
1.1.2Never BuiltWhy not?
1.0.3 Available View build log
1.0.0 Available View build log
Mac OS X (10.5+)
1.0.3
1.1.2Never BuiltWhy not?
1.0.3 Available View build log
1.0.0 Available View build log
Linux (32-bit)
1.0.3
1.1.2Never BuiltWhy not?
1.0.3 Available View build log
1.0.0 Available View build log
Linux (64-bit)
1.1.2 Available View build log
1.0.3 Available View build log
1.0.0 Available View build log
 
License
BSD
Imports
Lastest release
version 1.1.2 on May 24th, 2013

The OpenERP Client Library is a Python library to communicate with an OpenERP Server using its web services in an user-friendly way. It was created for those that doesn't want to code XML-RPC calls on the bare metal. It handles XML-RPC as well as JSON-RPC protocol and provides a bunch of syntaxic sugar to make things a lot easier.

The OpenERP Client Library is officially supported by OpenERP SA.

To consult the source code repository, report bugs or ask questions, see the Launchpad Project:

http://launchpad.net/openerp-client-lib

OpenERP Client Library Guide

First install the library:

sudo easy_install openerp-client-lib

Now copy-paste the following script describing a simple interaction with an OpenERP server:

import openerplib

connection = openerplib.get_connection(hostname="localhost", database="my_db", \
    login="my_user", password="xxx")
user_model = connection.get_model("res.users")
ids = user_model.search([("login", "=", "admin")])
user_info = user_model.read(ids[0], ["name"])
print user_info["name"]
# will print "Administrator"

In the previous script, the get_connection() method creates a Connection object that represents a communication channel with authentification to an OpenERP server. By default, get_connection() uses XML-RPC, but you can specify it to use JSON-RPC. You can also change the port. Example with a JSON-RPC communication on port 6080:

connection = openerplib.get_connection(hostname="localhost", protocol="jsonrpc", port=6080, ...)

The get_model() method on the Connection object creates a Model object. That object represents a remote model on the OpenERP server (for OpenERP addon programmers, those are also called osv). Model objects are dynamic proxies, which means you can remotely call methods in a natural way. In the previous script we demonstrate the usage of the search() and read() methods. That scenario is equivalent to the following interaction when you are coding an OpenERP addon and this code is executed on the server:

user_osv = self.pool.get('res.users')
ids = user_osv.search(cr, uid, [("login", "=", "admin")])
user_info = user_osv.read(cr, uid, ids[0], ["name"])

Also note that coding using Model objects offer some syntaxic sugar compared to vanilla addon coding:

  • You don't have to forward the "cr" and "uid" to all methods.

  • The read() method automatically sort rows according the order of the ids you gave it to.

  • The Model objects also provides the search_read() method that combines a search and a read, example:

    user_info = user_model.search_read([('login', '=', 'admin')], ["name"])[0]
    

Here are also some considerations about coding using the OpenERP Client Library:

  • Since you are using remote procedure calls, every call is executed inside its own transaction. So it can be dangerous, for example, to code multiple interdependant row creations. You should consider coding a method inside an OpenERP addon for such cases. That way it will be executed on the OpenERP server and so it will be transactional.
  • The browse() method can not be used. That method returns a dynamic proxy that lazy loads the rows' data from the database. That behavior is not implemented in the OpenERP Client Library.

Compatibility

  • 1.0
  • XML-RPC: OpenERP version 6.1 and superior
  • 1.1
  • XML-RPC: OpenERP version 6.1 and superior
  • JSON-RPC: OpenERP version 8.0 (upcoming) and superior

Changelog

  • 1.1.1:
  • Updated documentation
  • 1.1.0:
  • Added JsonRPC support
  • 1.0.4:
  • Removed netrpc handler
  • Added call to model methods with kwargs
  • 1.0.2:
  • added dates helper

Subscribe to package updates

Last updated May 24th, 2013

Download Stats

Last month:1

What does the lock icon mean?

Builds marked with a lock icon are only available via PyPM to users with a current ActivePython Business Edition subscription.

Need custom builds or support?

ActivePython Enterprise Edition guarantees priority access to technical support, indemnification, expert consulting and quality-assured language builds.

Plan on re-distributing ActivePython?

Get re-distribution rights and eliminate legal risks with ActivePython OEM Edition.