Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 18 additions & 46 deletions content/administration/odoo_online.rst
Original file line number Diff line number Diff line change
Expand Up @@ -160,49 +160,21 @@ Web Services
============

In order to programmatically retrieve the list of the databases displayed in the
`database manager <https://www.odoo.com/my/databases>`_, call the method `list` of the model
`odoo.database` via a :doc:`Web Service </developer/howtos/web_services>` call.

Inspired from the examples provided in the :doc:`Web Services </developer/howtos/web_services>`
section, this is how to retrieve this list with the library ``xmlrpc.client``::

import xmlrpc.client

USER = '[email protected]'
APIKEY = 'your_apikey'

root = 'https://www.odoo.com/xmlrpc/'
uid = xmlrpc.client.ServerProxy(root + 'common').login('openerp', USER, APIKEY)
sock = xmlrpc.client.ServerProxy(root + 'object')
databases_list = sock.execute('openerp', uid, APIKEY, 'odoo.database', 'list')

And here is the equivalent example with JSON-RPC::

import json
import random
import urllib.request

USER = '[email protected]'
APIKEY = 'your_apikey'

def json_rpc(url, method, params):
data = {
'jsonrpc': '2.0',
'method': method,
'params': params,
'id': random.randint(0, 1000000000),
}
req = urllib.request.Request(url=url, data=json.dumps(data).encode(), headers={
"Content-Type": "application/json",
})
reply = json.loads(urllib.request.urlopen(req).read().decode('UTF-8'))
if reply.get('error'):
raise Exception(reply['error'])
return reply['result']

def call(url, service, method, *args):
return json_rpc(url, 'call', {'service': service, 'method': method, 'args': args})

url = 'https://www.odoo.com/jsonrpc'
uid = call(url, 'common', 'login', 'openerp', USER, APIKEY)
databases_list = call(url, 'object', 'execute', 'openerp', uid, APIKEY, 'odoo.database', 'list')
`database manager <https://www.odoo.com/my/databases>`_, call the method ``list`` of the model
``odoo.database`` via an :doc:`external JSON-2 API </developer/reference/external_api>` call.

.. example::
.. code:: python

import requests

APIKEY = "your_apikey"

requests.post(
"https://www.odoo.com/json/2/odoo.database/list",
headers={
"Authorization": f"bearer {APIKEY}",
"X-Odoo-Database": "openerp",
}
json={},
)
6 changes: 0 additions & 6 deletions content/developer/howtos.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ How-to guides
howtos/frontend_owl_components
howtos/website_themes

howtos/web_services
howtos/company
howtos/create_reports
howtos/accounting_localization
Expand Down Expand Up @@ -69,11 +68,6 @@ Server-side development

.. cards::

.. card:: Web services
:target: howtos/web_services

Learn more about Odoo's web services.

.. card:: Multi-company guidelines
:target: howtos/company

Expand Down
148 changes: 0 additions & 148 deletions content/developer/howtos/web_services.rst

This file was deleted.

1 change: 1 addition & 0 deletions content/developer/reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ Reference
reference/cli
reference/upgrades
reference/external_api
reference/external_rpc_api
reference/extract_api
Loading