# odoorpc.rpc

This module provides Connector classes to communicate with an Odoo server with the JSON-RPC protocol or through simple HTTP requests.

Web controllers of Odoo expose two kinds of methods: json and http. These methods can be accessed from the connectors of this module.

class `odoorpc.rpc.``Connector`(host, port=8069, timeout=120, version=None)

  Connector base class defining the interface used to interact with a server.

  `ssl`

    Return True if SSL is activated.

  `timeout`

    Return the timeout.

class `odoorpc.rpc.``ConnectorJSONRPC`(host, port=8069, timeout=120, version=None, deserialize=True)

  Connector class using the JSON-RPC protocol.

      >>> from odoorpc import rpc
      >>> cnt = rpc.ConnectorJSONRPC('localhost', port=8069)

  Open a user session:

      >>> cnt.proxy_json.web.session.authenticate(db='db_name', login='admin', password='password')
      {'jsonrpc': '2.0', 'id': 202516757,
       'result': {'username': 'admin', 'user_context': {'lang': 'fr_FR', 'tz': 'Europe/Brussels', 'uid': 1},
       'db': 'db_name', 'company_id': 1, 'uid': 1, 'session_id': '308816f081394a9c803613895b988540'}}

  Read data of a partner:

      >>> cnt.proxy_json.web.dataset.call(model='res.partner', method='read', args=[[1]])
      {'jsonrpc': '2.0', 'id': 454236230,
       'result': [{'id': 1, 'comment': False, 'ean13': False, 'property_account_position': False, ...}]}

  You can send requests this way too:

      >>> cnt.proxy_json['/web/dataset/call'](model='res.partner', method='read', args=[[1]])
      {'jsonrpc': '2.0', 'id': 328686288,
       'result': [{'id': 1, 'comment': False, 'ean13': False, 'property_account_position': False, ...}]}

  Or like this:

      >>> cnt.proxy_json['web']['dataset']['call'](model='res.partner', method='read', args=[[1]])
      {'jsonrpc': '2.0', 'id': 102320639,
       'result': [{'id': 1, 'comment': False, 'ean13': False, 'property_account_position': False, ...}]}

  `proxy_http`

    Return the HTTP proxy.

  `proxy_json`

    Return the JSON proxy.

  `timeout`

    Return the timeout.

class `odoorpc.rpc.``ConnectorJSONRPCSSL`(host, port=8069, timeout=120, version=None, deserialize=True)

  Connector class using the JSON-RPC protocol over SSL.

      >>> from odoorpc import rpc
      >>> cnt = rpc.ConnectorJSONRPCSSL('localhost', port=8069)