Skip to content

Commit 5cd6745

Browse files
committed
Use the Webclient API by default for Odoo >= 9.0
1 parent e0e590f commit 5cd6745

File tree

13 files changed

+487
-194
lines changed

13 files changed

+487
-194
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: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ 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
@@ -25,8 +25,9 @@ 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 very close to the Odoo API, through Webclient API
2929
- compatible with OpenERP 6.1 through Odoo 19.0
30+
- supports external APIs JSON-RPC and XML-RPC as alternative
3031
- single executable ``odooly.py``, no external dependency
3132
- helpers for ``search``, for data model introspection, etc...
3233
- simplified syntax for search ``domain`` and ``fields``
@@ -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

docs/api.rst

Lines changed: 54 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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,38 @@ 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 of the ``/web`` API.
71+
72+
.. attribute:: Client.web_dataset
73+
74+
.. attribute:: Client.web_session
75+
76+
.. attribute:: Client.web_webclient
77+
78+
5379
Odoo RPC Services
5480
~~~~~~~~~~~~~~~~~
5581

82+
.. note::
83+
84+
These RPC services are deprecated in Odoo 19.0. They are
85+
scheduled for removal in Odoo 20.0 in 2026.
86+
5687
The naked Odoo RPC services are exposed too.
5788
The :attr:`~Client.db` and the :attr:`~Client.common` services expose few
5889
methods which might be helpful for server administration. Use the
@@ -92,12 +123,16 @@ Please refer to `the Odoo documentation`_ for more details.
92123

93124
Removed in OpenERP 7.
94125

126+
.. autoclass:: WebAPI
127+
:members:
128+
:undoc-members:
129+
95130
.. autoclass:: Service
96131
:members:
97132
:undoc-members:
98133

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

102137

103138
Environment
@@ -131,6 +166,16 @@ Environment
131166

132167
Cursor on the current database.
133168

169+
.. automethod:: session_authenticate
170+
171+
.. automethod:: session_destroy
172+
173+
.. attribute:: session_info
174+
175+
Dictionary returned when a Webclient session is authenticated.
176+
It contains ``uid`` and ``user_context`` among other user's preferences
177+
and server parameters.
178+
134179
.. automethod:: sudo(user=SUPERUSER_ID)
135180

136181

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

152197
.. automethod:: Env.execute(obj, method, *params, **kwargs)
153198

199+
.. automethod:: Env._call_kw(obj, method, *params, **kwargs)
200+
201+
.. attribute:: Env._web(obj, method, *params, **kwargs)
202+
203+
Expose the root of the ``/web`` API.
204+
154205
.. method:: Env.exec_workflow(obj, signal, obj_id)
155206

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

217268

218269
.. _model-and-records:
@@ -222,7 +273,7 @@ Model and Records
222273

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

227278
The :class:`Model` is instantiated using the ``client.env[...]`` syntax.
228279

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: 14 additions & 8 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,7 +102,7 @@ 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'>
105+
<Client 'http://localhost:8069/web#demo'>
100106
>>> client.db.list()
101107
['demo']
102108
>>> env
@@ -137,7 +143,7 @@ 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'>
146+
<Client 'http://localhost:8069/web#demo_test'>
141147
>>> client.db.list()
142148
['demo', 'demo_test']
143149
>>> env
@@ -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)