File: tuto_session.rst

package info (click to toggle)
python-odoorpc 0.10.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 604 kB
  • sloc: python: 3,461; makefile: 154; sh: 36
file content (38 lines) | stat: -rw-r--r-- 1,215 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
.. _tuto-manage-sessions:

Save your credentials (session)
-------------------------------

Once you are authenticated with your :class:`ODOO <odoorpc.ODOO>` instance, you
can :func:`save <odoorpc.ODOO.save>` your credentials under a code name and use
this one to quickly instantiate a new :class:`ODOO <odoorpc.ODOO>` class::

    >>> import odoorpc
    >>> odoo = odoorpc.ODOO('localhost')
    >>> user = odoo.login('tutorial', 'admin', 'admin')
    >>> odoo.save('tutorial')

By default, these informations are stored in the ``~/.odoorpcrc`` file. You can
however use another file::

    >>> odoo.save('tutorial', '~/my_own_odoorpcrc')

Then, use the :func:`odoorpc.ODOO.load` class method::

    >>> import odoorpc
    >>> odoo = odoorpc.ODOO.load('tutorial')

Or, if you have saved your configuration in another file::

    >>> odoo = odoorpc.ODOO.load('tutorial', '~/my_own_odoorpcrc')

You can check available sessions with :func:`odoorpc.ODOO.list`, and remove
them with :func:`odoorpc.ODOO.remove`::

    >>> odoorpc.ODOO.list()
    ['tutorial']
    >>> odoorpc.ODOO.remove('tutorial')
    >>> 'tutorial' not in odoorpc.ODOO.list()
    True

:ref:`Next step: Configure logging with OdooRPC <tuto-logging>`