Skip to main content

Odoo RPC client

Project description

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.

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.

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

Project details


Download files

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

Source Distribution

s6r_odoo-2.3.0.tar.gz (30.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

s6r_odoo-2.3.0-py3-none-any.whl (24.3 kB view details)

Uploaded Python 3

File details

Details for the file s6r_odoo-2.3.0.tar.gz.

File metadata

  • Download URL: s6r_odoo-2.3.0.tar.gz
  • Upload date:
  • Size: 30.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for s6r_odoo-2.3.0.tar.gz
Algorithm Hash digest
SHA256 832877ea3b88d778d557ad3c20bdcd96cb93925e9c36cac9b6d1b5c54614469d
MD5 63c4ace40af9e017a31f199477af1752
BLAKE2b-256 060f832bd063a7466c03ba83c360f16379673d52d6b6fa434d0ec4327ca36c6d

See more details on using hashes here.

File details

Details for the file s6r_odoo-2.3.0-py3-none-any.whl.

File metadata

  • Download URL: s6r_odoo-2.3.0-py3-none-any.whl
  • Upload date:
  • Size: 24.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for s6r_odoo-2.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 70004fa944ea05b67eabe9220e3daf16310c7dc48da9c4621b43ebbf966cd68e
MD5 8d544d8aaaeb64b2f45d598bea98e474
BLAKE2b-256 7ae6335213fe82edbb21b9ab282fe3089623f201ae2055e2e0ca24ffbc437da0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page