Book Image

Odoo Development Cookbook

By : Holger Brunn, Alexandre Fayolle, Daniel Reis
Book Image

Odoo Development Cookbook

By: Holger Brunn, Alexandre Fayolle, Daniel Reis

Overview of this book

Odoo is a full-featured open source ERP with a focus on extensibility. The flexibility and sustainability of open source is also a key selling point of Odoo. It is built on a powerful framework for rapid application development, both for back-end applications and front-end websites. The book starts by covering Odoo installation and administration, and provides a gentle introduction to application development. It then dives deep into several of the areas that an experienced developer will need to use. You’ll learn implement business logic, adapt the UI, and extend existing features.
Table of Contents (23 chapters)
Odoo Development Cookbook
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Using the RPC API


One of Odoo's strengths is its interoperability, which is helped by the fact that basically any functionality is available via JSON-RPC 2.0 and XMLRPC. In this recipe, we'll explore how to use both of them from client code. This interface also enables you to integrate Odoo with any other application. Making functionality available via any of the two protocols on the server side is explained in the There's more section of this recipe.

We'll query a list of installed modules from the Odoo instance, so that we could show a list like the one displayed in the previous recipe in our own application or website.

How to do it…

The following code is not meant to run within Odoo, but as simple scripts:

  1. First, we query the list of installed modules via XMLRPC:

    #!/usr/bin/env python2
    import xmlrpclib
    
    db = 'odoo9'
    user = 'admin'
    password = 'admin'
    uid = xmlrpclib.ServerProxy('http://localhost:8069/xmlrpc/2/common')\
        .authenticate(db, user, password, {})
    odoo = xmlrpclib.ServerProxy(...