Debian Codegraph @

odoorpc/__init__.py

raw
1 # -*- coding: utf-8 -*-
2 # Copyright 2014 Sébastien Alix
3 # License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl)
4 """The `odoorpc` module defines the :class:`ODOO` class.
5
6 The :class:`ODOO` class is the entry point to manage `Odoo` servers.
7 You can use this one to write `Python` programs that performs a variety of
8 automated jobs that communicate with a `Odoo` server.
9
10 Here's a sample session using this module::
11
12 >>> import odoorpc
13 >>> odoo = odoorpc.ODOO('localhost', port=8069) # connect to localhost, default port
14 >>> odoo.login('dbname', 'admin', 'admin')
15
16 To catch debug logs of OdooRPC from your own code, you have to configure
17 a logger the way you want with a log level set to `DEBUG`::
18
19 >>> import logging
20 >>> logging.basicConfig()
21 >>> logger = logging.getLogger('odoorpc')
22 >>> logger.setLevel(logging.DEBUG)
23
24 Then all queries generated by OdooRPC will be logged::
25
26 >>> import odoorpc
27 >>> odoo = odoorpc.ODOO()
28 >>> odoo.login('dbname', 'admin', 'admin')
29 DEBUG:odoorpc.rpc.jsonrpclib:(JSON,send) http://localhost:8069/web/session/authenticate {'jsonrpc': '2.0', 'id': 499807971, 'method': 'call', 'params': {'db': 'dbname', 'login': 'admin', 'password': '**********'}}
30 DEBUG:odoorpc.rpc.jsonrpclib:(JSON,recv) http://localhost:8069/web/session/authenticate {'jsonrpc': '2.0', 'id': 499807971, 'method': 'call', 'params': {'db': 'dbname', 'login': 'admin', 'password': '**********'}} => {'result': {'is_admin': True, 'server_version': '12.0-20181008', 'currencies': {'2': {'digits': [69, 2], 'position': 'before', 'symbol': '$'}, '1': {'digits': [69, 2], 'position': 'after', 'symbol': '€'}}, 'partner_display_name': 'YourCompany, Mitchell Admin', 'company_id': 1, 'username': 'admin', 'web_tours': [], 'user_companies': False, 'session_id': '61cb37d21771531f789bea631a03236aa21f06d4', 'is_system': True, 'server_version_info': [12, 0, 0, 'final', 0, ''], 'db': 'odoorpc_v12', 'name': 'Mitchell Admin', 'web.base.url': 'http://localhost:8069', 'user_context': {'lang': 'fr_FR', 'tz': 'Europe/Brussels', 'uid': 2}, 'odoobot_initialized': True, 'show_effect': 'True', 'partner_id': 3, 'uid': 2}, 'id': 499807971, 'jsonrpc': '2.0'}
31 """
32
33 __author__ = 'ABF Osiell - Sebastien Alix'
34 __email__ = '[email protected]'
35 __licence__ = 'LGPL v3'
36 __version__ = '0.10.1'
37
38 __all__ = ['ODOO', 'error']
39
40 import logging
41
42 from odoorpc import error
43 from odoorpc.odoo import ODOO
44
45 logging.getLogger(__name__).addHandler(logging.NullHandler())