Skip to main content

Utilities to make better use of OdooRPC

Project description


This module offers functions to:

  1. Instantiate common Odoo RPC libraries from a single .ini file (currently odooly and odoorpc supported);

  2. Run DEEP read and search_read queries, retrieving data from multiple models at once, in an efficient manner and using parallel execution of RPCs;

  3. The function to support deep queries can also be used as a building block to support GraphQL or GraphQL-like querying.


  • Extend the utils package to support GraphQL queries;
  • Write an odoorpc_fast class to speed-up RPC queries by using HTTP sessions and gzip encoding;
  • Many, many potential functionalities... feel free to help writing and suggesting!

Example 1:

from odoorpc_utils import FastDeepQueries, OdooInstantiator

# read from file odoorpc_utils.ini, odoorpc-utils.ini or odooly.ini
# If you prefer you can skip this and instantiate odoorpc the old way.
odoo = OdooInstantiator.odoorpc_from_config_file('production')

# pass an instance of logged-in odoorpc here (odooly not supported at the moment)
fdq = FastDeepQueries(odoo)

# Let's get the id of 100 sales orders...
ids = fdq.query_fast(model_name='sale.order', limit=100)

# The fields you want to retrieve are specified in this easy to understand syntax...
fields = ['number,date_confirmed,order_total',
          'sale_order_line_ids.quantity, unit_price, total_price',

# ...which is then parsed, relations are retrieved and a more complex structure of dicts is built
fields_deep = fdq.build_fields_deep_structure(model_name='sale.order', fields_deep=fields)

# Now let's make a deep query for 100 sales order and see how fast it is 
# Nope, it will not be blazing fast, it will actually be quite slow, but MUCH faster 
# than what you usually get from odoorpc...
res = fdq.query_deep(fields_deep, ids=ids, n_threads=8)

# Done!

# RPC is slow... each query takes ~1 second, larger queries can take much longer. Running them in
# parallel speeds things up significantly (but it is still RPC)


Example 2:

from odoorpc_utils import FastDeepQueries, OdooInstantiator

odoo = OdooInstantiator.odoorpc_from_config_file('production')    
fdq = FastDeepQueries(odoo)

# We can also run queries defined on a queries.ini file
res = fdq.named_query('picking list report', ids=[order_id])

Sample odoorpc_utils.ini file:

port = 443
username = user
password = pass

# Odooly-specific
scheme = https
protocol = jsonrpc

timeout = 3600
# if **protocol_odoorpc** is missing, the param protocol will be
# used with odoorpc instead. But Odooly and OdooRPC do not support the same
# syntax for the protocol string, hence why an odoorpc-specific option exists
protocol_odoorpc = jsonrpc+ssl

host =
database = my_production_database

host =
database = testing_database

Sample queries.ini file

# acceptable values are all parameters of the query_deep function
# with the exception of fields_deep that MUST be provided by means of the
# fields *model name* and *fields*.
n_threads = 8
strip_name_from__id_fields = True

[picking list report]
model name = sale.order
fields = number,date_confirmed,order_total
fields =,address,zip,city,state,tax_number
fields = sale_order_line_ids.quantity, unit_price, total_price
fields =,reference

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for odoorpc-utils, version 0.2.2
Filename, size File type Python version Upload date Hashes
Filename, size odoorpc_utils-0.2.2-py3-none-any.whl (15.5 kB) File type Wheel Python version py3 Upload date Hashes View hashes
Filename, size odoorpc-utils-0.2.2.tar.gz (6.2 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page