Skip to content

Commit 96e0a2e

Browse files
committed
Use the Webclient API by default for Odoo >= 9.0
1 parent 60ceab7 commit 96e0a2e

File tree

13 files changed

+508
-203
lines changed

13 files changed

+508
-203
lines changed

.github/workflows/python-package.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ name: Odooly
55

66
on:
77
push:
8-
branches: [ "master" ]
8+
branches: [ "master", "dev" ]
99
pull_request:
10-
branches: [ "master" ]
10+
branches: [ "master", "dev" ]
1111

1212
jobs:
1313
build:

CHANGES.rst

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,20 @@ Changelog
55
2.x.x (unreleased)
66
~~~~~~~~~~~~~~~~~~
77

8-
* Use a Web session for JSON-RPC requests
9-
when Requests is installed.
8+
* Support webclient :class:`WebAPI` protocol as an alternative:
9+
``/web/dataset/*``, ``/web/database/*``, ...
10+
Webclient API is stable since Odoo 9.0
11+
12+
* Authenticate with ``/web/session/authenticate`` by default
13+
and retrieve :attr:`Env.session_info`, with Odoo >= 9.0.
14+
15+
* Use Webclient API by default when ``protocol`` is not set.
16+
It is same as setting ``protocol = web``
17+
18+
* New function :meth:`Client.drop_database`.
19+
20+
* New functions to create/destroy a session:
21+
:meth:`Env.session_authenticate` and :meth:`Env.session_destroy`.
1022

1123
* Drop support for Python 3.5
1224

README.rst

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ Download and install the latest release::
1010
:local:
1111
:backlinks: top
1212

13-
Documentation and tutorial: http://odooly.readthedocs.org
13+
Documentation and tutorial: https://odooly.readthedocs.io/
1414

1515

1616
Overview
1717
--------
1818

19-
Odooly carries three completing uses:
19+
Odooly carries three modes of use:
2020

2121
(1) with command line arguments
2222
(2) as an interactive shell
@@ -25,14 +25,15 @@ Odooly carries three completing uses:
2525

2626
Key features:
2727

28-
- provides an API very close to the Odoo API, through JSON-RPC and XML-RPC
28+
- provides an API similar to Odoo Model, through Webclient API
2929
- compatible with OpenERP 6.1 through Odoo 19.0
30-
- single executable ``odooly.py``, no external dependency
30+
- supports external APIs JSON-RPC and XML-RPC as alternative
31+
- single file ``odooly.py``, no external dependency
3132
- helpers for ``search``, for data model introspection, etc...
3233
- simplified syntax for search ``domain`` and ``fields``
3334
- full API accessible on the ``Client.env`` environment
3435
- the module can be imported and used as a library: ``from odooly import Client``
35-
- supports Python 3.6 and above
36+
- supports Python 3.6 and more recent
3637

3738

3839

@@ -59,7 +60,7 @@ Although it is quite limited::
5960
-c CONFIG, --config=CONFIG
6061
specify alternate config file (default: 'odooly.ini')
6162
--server=SERVER full URL of the server (default:
62-
http://localhost:8069/xmlrpc)
63+
http://localhost:8069/web)
6364
-d DB, --db=DB database
6465
-u USER, --user=USER username
6566
-p PASSWORD, --password=PASSWORD
@@ -113,7 +114,7 @@ Edit ``odooly.ini`` and declare the environment(s)::
113114
[demo]
114115
username = demo
115116
password = demo
116-
protocol = xmlrpc
117+
protocol = web
117118

118119
[demo_jsonrpc]
119120
username = demo
@@ -164,6 +165,6 @@ This is a sample session::
164165

165166
.. note::
166167

167-
To preserve the history of commands when closing the session, first
168+
To preserve the commands' history when closing the session, first
168169
create an empty file in your home directory:
169170
``touch ~/.odooly_history``

docs/api.rst

Lines changed: 70 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ The library provides few objects to access the Odoo model and the
88
associated services of `the Odoo API`_.
99

1010
The signature of the methods mimics the standard methods provided by the
11-
:class:`osv.Model` Odoo class. This is intended to help the developer when
11+
:class:`odoo.models.Model` Odoo class. This is intended to help the developer when
1212
developping addons. What is experimented at the interactive prompt should
1313
be portable in the application with little effort.
1414

@@ -21,9 +21,9 @@ be portable in the application with little effort.
2121
Client and Services
2222
-------------------
2323

24-
The :class:`Client` object provides thin wrappers around Odoo RPC services
25-
and their methods. Additional helpers are provided to explore the models and
26-
list or install Odoo add-ons.
24+
The :class:`Client` object provides thin wrappers around Odoo Webclient API
25+
and RPC services and their methods. Additional helpers are provided to explore
26+
the models and to list or to install Odoo add-ons.
2727

2828

2929
.. autoclass:: Client
@@ -34,6 +34,8 @@ list or install Odoo add-ons.
3434

3535
.. automethod:: Client.clone_database
3636

37+
.. automethod:: Client.drop_database
38+
3739
.. automethod:: Client.login
3840

3941

@@ -50,9 +52,44 @@ list or install Odoo add-ons.
5052
``ODOOLY_SSL_UNVERIFIED=1``.
5153

5254

55+
Odoo Webclient API
56+
~~~~~~~~~~~~~~~~~~
57+
58+
These HTTP routes were developed for the Odoo Web application. They are now
59+
used by Odooly to provide high level methods on :class:`Env`
60+
and :class:`Model`.
61+
62+
.. attribute:: Client.database
63+
64+
Expose the ``database`` :class:`WebAPI`.
65+
66+
Example: :meth:`Client.database.list` method.
67+
68+
.. attribute:: Client.web
69+
70+
Expose the root ``/web`` :class:`WebAPI`.
71+
72+
.. attribute:: Client.web_dataset
73+
74+
Expose the ``/web/dataset`` :class:`WebAPI`.
75+
76+
.. attribute:: Client.web_session
77+
78+
Expose the ``/web/session`` :class:`WebAPI`.
79+
80+
.. attribute:: Client.web_webclient
81+
82+
Expose the ``/web/webclient`` :class:`WebAPI`.
83+
84+
5385
Odoo RPC Services
5486
~~~~~~~~~~~~~~~~~
5587

88+
.. note::
89+
90+
These RPC services are deprecated in Odoo 19.0. They are
91+
scheduled for removal in Odoo 20.0 in 2026.
92+
5693
The naked Odoo RPC services are exposed too.
5794
The :attr:`~Client.db` and the :attr:`~Client.common` services expose few
5895
methods which might be helpful for server administration. Use the
@@ -70,16 +107,22 @@ Please refer to `the Odoo documentation`_ for more details.
70107
Examples: :meth:`Client.db.list` or :meth:`Client.db.server_version`
71108
RPC methods.
72109

110+
Removed in Odoo 20.
111+
73112
.. attribute:: Client.common
74113

75114
Expose the ``common`` :class:`Service`.
76115

77116
Example: :meth:`Client.common.login_message` RPC method.
78117

118+
Removed in Odoo 20.
119+
79120
.. data:: Client._object
80121

81122
Expose the ``object`` :class:`Service`.
82123

124+
Removed in Odoo 20.
125+
83126
.. attribute:: Client._report
84127

85128
Expose the ``report`` :class:`Service`.
@@ -92,12 +135,16 @@ Please refer to `the Odoo documentation`_ for more details.
92135

93136
Removed in OpenERP 7.
94137

138+
.. autoclass:: WebAPI
139+
:members:
140+
:undoc-members:
141+
95142
.. autoclass:: Service
96143
:members:
97144
:undoc-members:
98145

99146
.. _the Odoo documentation:
100-
.. _the Odoo API: http://doc.odoo.com/v6.1/developer/12_api.html#api
147+
.. _the Odoo API: https://www.odoo.com/documentation/19.0/developer/reference/external_rpc_api.html
101148

102149

103150
Environment
@@ -131,6 +178,16 @@ Environment
131178

132179
Cursor on the current database.
133180

181+
.. automethod:: session_authenticate
182+
183+
.. automethod:: session_destroy
184+
185+
.. attribute:: session_info
186+
187+
Dictionary returned when a Webclient session is authenticated.
188+
It contains ``uid`` and ``user_context`` among other user's preferences
189+
and server parameters.
190+
134191
.. automethod:: sudo(user=SUPERUSER_ID)
135192

136193

@@ -151,6 +208,12 @@ Please refer to `the Odoo documentation`_ for details.
151208

152209
.. automethod:: Env.execute(obj, method, *params, **kwargs)
153210

211+
.. automethod:: Env._call_kw(obj, method, *params, **kwargs)
212+
213+
.. attribute:: Env._web(obj, method, *params, **kwargs)
214+
215+
Expose the root of the ``/web`` API.
216+
154217
.. method:: Env.exec_workflow(obj, signal, obj_id)
155218

156219
Wrapper around ``object.exec_workflow`` RPC method.
@@ -212,7 +275,7 @@ Python script or interactively in a Python session.
212275
It is not recommended to install or upgrade modules in offline mode when
213276
any web server is still running: the operation will not be signaled to
214277
other processes. This restriction does not apply when connected through
215-
XML-RPC or JSON-RPC.
278+
Webclient API or other RPC API.
216279

217280

218281
.. _model-and-records:
@@ -222,7 +285,7 @@ Model and Records
222285

223286
The :class:`Env` provides a high level API similar to the Odoo API, which
224287
encapsulates objects into `Active Records
225-
<http://www.martinfowler.com/eaaCatalog/activeRecord.html>`_.
288+
<https://www.martinfowler.com/eaaCatalog/activeRecord.html>`_.
226289

227290
The :class:`Model` is instantiated using the ``client.env[...]`` syntax.
228291

docs/developer.rst

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,13 @@ complex tasks.
2222
For example:
2323

2424
* write unit tests using the standard `unittest
25-
<http://docs.python.org/library/unittest.html>`_ framework.
26-
* write BDD tests using the `Gherkin language <http://packages.python.org/
27-
behave/gherkin.html#gherkin-feature-testing-language>`_, and a library
28-
like `Behave <http://packages.python.org/behave/>`_.
25+
<https://docs.python.org/library/unittest.html>`_ framework.
26+
* write BDD tests using the `Gherkin language <https://behave.readthedocs.io/
27+
en/latest/gherkin/#gherkin-feature-testing-language>`_, and a library
28+
like `Behave <https://behave.readthedocs.io/>`_.
2929
* build an interface for Odoo, using a framework like
30-
`Flask <http://flask.pocoo.org/>`_ (HTML, JSON, SOAP, ...).
30+
`Flask <https://flask.palletsprojects.com/>`_ (HTML, JSON, SOAP, ...).
31+
3132

3233

3334
Changes

docs/index.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Odooly's documentation
1010
*A versatile tool for browsing Odoo / OpenERP data*
1111

1212
The Odooly library communicates with any `Odoo / OpenERP server`_ (>= 6.1)
13-
using `the standard XML-RPC interface`_ or the new JSON-RPC interface.
13+
using the Webclient API or `the deprecated external RPC interface`_ (JSON-RPC or XML-RPC).
1414

1515
It provides both a :ref:`fully featured low-level API <client-and-services>`,
1616
and an encapsulation of the methods on :ref:`Active Record objects
@@ -35,11 +35,11 @@ Contents:
3535
tutorial
3636
developer
3737

38-
* Online documentation: http://odooly.readthedocs.org/
38+
* Online documentation: https://odooly.readthedocs.io/
3939
* Source code and issue tracker: https://github.com/tinyerp/odooly
4040

41-
.. _Odoo / OpenERP server: http://doc.odoo.com/
42-
.. _the standard XML-RPC interface: http://doc.odoo.com/v6.1/developer/12_api.html#api
41+
.. _Odoo / OpenERP server: https://www.odoo.com/documentation/
42+
.. _the deprecated external RPC interface: https://www.odoo.com/documentation/19.0/developer/reference/external_rpc_api.html
4343

4444

4545
Indices and tables

docs/intro.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Installation
1010
------------
1111

1212
Download and install the `latest release
13-
<http://pypi.python.org/pypi/Odooly>`__ from PyPI::
13+
<https://pypi.org/project/Odooly>`__ from PyPI::
1414

1515
pip install -U odooly
1616

docs/tutorial.rst

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Tutorial
66

77
This tutorial demonstrates some features of Odooly in the interactive shell.
88

9-
It assumes an Odoo or OpenERP server is installed.
9+
It assumes an Odoo server is installed.
1010
The shell is a true Python shell. We have access to all the features and
1111
modules of the Python interpreter.
1212

@@ -32,12 +32,17 @@ If our configuration is different, then we use arguments, like::
3232

3333
$ odooly --server http://192.168.0.42:8069
3434

35-
It connects using the XML-RPC protocol. If you want to use the JSON-RPC
36-
protocol instead, then pass the full URL with ``/jsonrpc`` path::
35+
It connects using the Webclient API. If you want to use the JSON-RPC
36+
external API instead, then pass the full URL with ``/jsonrpc`` path::
3737

3838
$ odooly --server http://127.0.0.1:8069/jsonrpc
3939

4040

41+
.. note::
42+
43+
These protocols JSON-RPC and XML-RPC are deprecated in Odoo 19.0 and will
44+
be removed in Odoo 20.0.
45+
4146
On login, it prints few lines about the commands available.
4247

4348
.. sourcecode:: pycon
@@ -64,6 +69,7 @@ On login, it prints few lines about the commands available.
6469
env.install(module1, module2, ...)
6570
env.upgrade(module1, module2, ...)
6671
# Install or upgrade the modules
72+
env.upgrade_cancel() # Reset failed upgrade/install
6773

6874
And it confirms that the default database is not available::
6975

@@ -73,9 +79,9 @@ And it confirms that the default database is not available::
7379
Though, we have a connected client, ready to use::
7480

7581
>>> client
76-
<Client 'http://localhost:8069/xmlrpc#()'>
82+
<Client 'http://localhost:8069/web#()'>
7783
>>> client.server_version
78-
'6.1'
84+
'18.0'
7985
>>> #
8086

8187

@@ -96,8 +102,8 @@ Default password is ``"admin"``.
96102
>>> client.create_database('super_password', 'demo')
97103
Logged in as 'admin'
98104
>>> client
99-
<Client 'http://localhost:8069/xmlrpc#demo'>
100-
>>> client.db.list()
105+
<Client 'http://localhost:8069/web#demo'>
106+
>>> client.database.list()
101107
['demo']
102108
>>> env
103109
<Env 'admin@demo'>
@@ -137,8 +143,8 @@ database name and the superadmin password.
137143
>>> client.clone_database('super_password', 'demo_test')
138144
Logged in as 'admin'
139145
>>> client
140-
<Client 'http://localhost:8069/xmlrpc#demo_test'>
141-
>>> client.db.list()
146+
<Client 'http://localhost:8069/web#demo_test'>
147+
>>> client.database.list()
142148
['demo', 'demo_test']
143149
>>> env
144150
<Env 'admin@demo'>
@@ -160,7 +166,7 @@ Where is the table for the users?
160166
.. sourcecode:: pycon
161167

162168
>>> client
163-
<Client 'http://localhost:8069/xmlrpc#demo'>
169+
<Client 'http://localhost:8069/web#demo'>
164170
>>> env.models('user')
165171
['res.users', 'res.users.log']
166172

0 commit comments

Comments
 (0)