Odoo

After creating an Odoo connection in Dashboard, connecting to its databases and issuing requests looks like as in the code below. Note that the underlying connections are based on openerp-client-lib and allow for everything the Odoo client supports.

# -*- coding: utf-8 -*-

# Zato
from zato.server.service import Service

class MyService(Service):

    def handle(self):
        with self.outgoing.odoo.get('My Connection').conn.client() as client:

            # Use openerplib's syntax
            user_model = client.get_model('res.users')
            ids = user_model.search([('login', '=', 'admin')])
            user_info = user_model.read(ids[0], ['login'])

            # Let's check out what we have
            self.logger.info(user_info)

            # The actual connection's implementation
            self.logger.info(client)
INFO - {'login': 'admin', 'id': 1}
INFO - <openerplib.main.Connection object at 0x7f1b585c9350>