| 1 |
.. _tuto-manage-sessions: |
| 2 |
|
| 3 |
Save your credentials (session) |
| 4 |
------------------------------- |
| 5 |
|
| 6 |
Once you are authenticated with your :class:`ODOO <odoorpc.ODOO>` instance, you |
| 7 |
can :func:`save <odoorpc.ODOO.save>` your credentials under a code name and use |
| 8 |
this one to quickly instantiate a new :class:`ODOO <odoorpc.ODOO>` class:: |
| 9 |
|
| 10 |
>>> import odoorpc |
| 11 |
>>> odoo = odoorpc.ODOO('localhost') |
| 12 |
>>> user = odoo.login('tutorial', 'admin', 'admin') |
| 13 |
>>> odoo.save('tutorial') |
| 14 |
|
| 15 |
By default, these informations are stored in the ``~/.odoorpcrc`` file. You can |
| 16 |
however use another file:: |
| 17 |
|
| 18 |
>>> odoo.save('tutorial', '~/my_own_odoorpcrc') |
| 19 |
|
| 20 |
Then, use the :func:`odoorpc.ODOO.load` class method:: |
| 21 |
|
| 22 |
>>> import odoorpc |
| 23 |
>>> odoo = odoorpc.ODOO.load('tutorial') |
| 24 |
|
| 25 |
Or, if you have saved your configuration in another file:: |
| 26 |
|
| 27 |
>>> odoo = odoorpc.ODOO.load('tutorial', '~/my_own_odoorpcrc') |
| 28 |
|
| 29 |
You can check available sessions with :func:`odoorpc.ODOO.list`, and remove |
| 30 |
them with :func:`odoorpc.ODOO.remove`:: |
| 31 |
|
| 32 |
>>> odoorpc.ODOO.list() |
| 33 |
['tutorial'] |
| 34 |
>>> odoorpc.ODOO.remove('tutorial') |
| 35 |
>>> 'tutorial' not in odoorpc.ODOO.list() |
| 36 |
True |
| 37 |
|
| 38 |
:ref:`Next step: Configure logging with OdooRPC <tuto-logging>` |