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.
Connector base class defining the interface used to interact with a server.
Return True if SSL is activated.
Return the timeout.
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, ...}]}
Return the HTTP proxy.
Return the JSON proxy.
Return the timeout.
Connector class using the JSON-RPC protocol over SSL.
>>> from odoorpc import rpc
>>> cnt = rpc.ConnectorJSONRPCSSL('localhost', port=8069)