Skip to main content

s6r-odoo

Installation

    pip install s6r-odoo

Usage

from s6r_odoo import OdooConnection

odoo = OdooConnection(url='http://odoo.localhost',
                          dbname='odoo',
                          user='admin',
                          password='admin')
res_partner = odoo.model('res.partner')
partner_ids = res_partner.search([],  fields=['name', 'email'])
for partner_id in partner_ids:
    print(f'{partner_id.name} : {partner_id.email}')

JSON-2 API (Odoo 19+)

Starting with Odoo 19, the library uses the JSON-2 API instead of XML-RPC. The password parameter must be an API key (not a user password).

from s6r_odoo import OdooConnection

odoo = OdooConnection(url='https://myodoo.example.com',
                          dbname='mydb',
                          user='admin',
                          password='your_api_key_here',
                          version=19)

For Odoo versions < 19, the library continues to use XML-RPC with the user password as before.

Requirements

The JSON-2 endpoint is provided by the Odoo rpc module (installed automatically, as an auto_install module depending on base). It must be installed in the target database: if it has been uninstalled, the library raises an explicit error. It does not need to be loaded as a server-wide module, since the database is selected with the X-Odoo-Database header. XML-RPC, on the contrary, requires rpc in server_wide_modules when the database cannot be determined from the hostname (dbfilter).

Generating an API key

API keys can be created from the Odoo web interface: Settings > Users > Select user > API Keys tab > New API Key

How it works

XML-RPC (Odoo <= 18) JSON-2 (Odoo >= 19)
Endpoint /xmlrpc/2/object /json/2/<model>/<method>
Auth uid + password per call Authorization: bearer <api_key> header
Database Passed in every call X-Odoo-Database header
Arguments Positional Named (JSON body)

All existing methods (search, read, write, create, unlink, load, fields_get, read_group, etc.) work transparently with both protocols.

Other methods are called with execute(). With JSON-2, their arguments must be passed as keyword arguments, the record ids with ids= (this syntax also works with XML-RPC):

partners = odoo.model('res.partner')
partners.execute('name_search', name='Azure', limit=5)
partners.execute('copy', ids=[42], default={'name': 'Copy'})

HTTP basic authentication (http_user / http_password) is not supported with JSON-2: both use the Authorization header.

Testing in local environment

Setup environment

To run the tests locally, first install pytest in your venv

pip install --upgrade pytest pytest-env
# pytest-env is an optional package to handle .env variables

Then from the repository root directory, install the s6r-odoo module in editable mode in your venv:

pip install -e ./

Edit /tests/pytest.ini to setup the tests config file

[pytest]
log_cli=true
log_level=WARNING
;WARNING produces a very nice and readable output, use DEBUG or INFO if you need to catch odoo-configurator logs or test logs 
log_format = %(asctime)s %(levelname)s %(message)s
log_date_format = %Y-%m-%d %H:%M:%S
env =
    ODOO_V16_PASSWORD=
    ODOO_V17_PASSWORD=
    ODOO_V18_PASSWORD=
    ODOO_V19_API_KEY=
; You need to fill these password/api_key env variables

For now, this is where we manage the passwords to access testing Odoo instances.

Run the tests

Go to the /tests directory cd tests, then just run:

pytest

If you are using Pycharm, this article explains in details the configuration: https://pytest-with-eric.com/integrations/pytest-pycharm-integration/#Configuring-PyCharm-for-Pytest-Optional

License

This project is licensed under the GNU Lesser General Public License (LGPL) Version 3.

Contributing

Contributions are welcome! If you find any issues or have suggestions for improvements, please open an issue or submit a pull request.

Contributors

Maintainer

This software is maintained by Scalizer.

Scaliser

Metadata

Release files for s6r-odoo 2.3.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for s6r-odoo 2.3.2
File Size Uploaded Provenance Actions
s6r_odoo-2.3.2.tar.gz 33.7 kB Without provenance Details for s6r_odoo-2.3.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for s6r-odoo 2.3.2
File Interpreter ABI Platform Actions
s6r_odoo-2.3.2-py3-none-any.whl Python 3 none any Details for s6r_odoo-2.3.2-py3-none-any.whl

Total release size: 59.3 kB

Release files / s6r_odoo-2.3.2.tar.gz

Download URL s6r_odoo-2.3.2.tar.gz
Size 33.7 kB
Tags Source
SHA-256 checksum
How to use checksums
ac150356dce3aacb2ea980df6d7e1a937ef895ba9f6983c1ff7ac2d959f65d01
BLAKE2b-256 checksum
How to use checksums
46556e9362794bde18b70e0fb67236a983c8fddbdd102a9163f4240e2685cc9f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / s6r_odoo-2.3.2-py3-none-any.whl

Download URL s6r_odoo-2.3.2-py3-none-any.whl
Size 25.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
33f27dc10bc1d7a8bfb07625cf417945bd2e0c01258e63ce521717156f223175
BLAKE2b-256 checksum
How to use checksums
113734f1c7a17131325cc9f21b1d1853f2306c938d449752514dc762ae4ee8c4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Security for s6r-odoo 2.3.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

2.3.2 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page