Skip to main content

Python client library for Odoo and the OpenStack integration add-on.

Project description

OpenStack Odoo Client Library for Python

PyPI PyPI - Python Version GitHub Test Status

This is an Odoo client library for Python with support for the OpenStack Integration add-on, intended to be used by OpenStack projects such as Distil.

This library provides a higher level interface than OdooRPC (which is used internally), and is intended to make it possible to develop applications against a well-defined API, without having to take into account considerations such as backward-incompatible changes between Odoo versions.

Installation

The OpenStack Odoo Client library supports Python 3.10 and later.

To install the library package, simply install the openstack-odooclient package using pip.

python -m pip install openstack-odooclient

Connecting to Odoo

To connect to an Odoo server, create an openstack_odooclient.Client object and pass the connection details to it.

openstack_odooclient.Client(
    *,
    hostname: str,
    database: str,
    username: str,
    password: str,
    protocol: str = "jsonrpc",
    port: int = 8069,
    verify: bool | str | Path = True,
    version: str | None = None,
) -> Client

This is the recommended way of creating the Odoo client object, as it provides some extra parameters for convenience.

from openstack_odooclient import Client as OdooClient

odoo_client = OdooClient(
    hostname="localhost",
    database="odoodb",
    user="test-user",
    password="<password>",
    protocol="jsonrpc",  # HTTP, or "jsonrpc+ssl" for HTTPS.
    port=8069,
    # verify=True,  # Enable/disable SSL verification, or pass the path to a CA certificate.
    # version="14.0",  # Optionally specify the server version. Default is to auto-detect.
)

If you have a pre-existing odoorpc.ODOO connection object, that can instead be passed directly into openstack_odooclient.Client.

openstack_odooclient.Client(*, odoo: odoorpc.ODOO) -> Client

This allows for sharing a single OdooRPC connection object with other code.

from odoorpc import ODOO
from openstack_odooclient import Client as OdooClient

odoo = ODOO(
    host="localhost",
    port=8069,
    protocol="jsonrpc",  # HTTP, or "jsonrpc+ssl" for HTTPS.
    # version="14.0",  # Optionally specify the server version. Default is to auto-detect.
)
odoo.login("odoodb", "test-user", "<password>")

odoo_client = OdooClient(odoo=odoo)

Managers

The Odoo client object exposes a number of record managers, which contain methods used to query specific record types, or create one or more new records of that type.

For example, performing a simple search query would look something like this:

>>> from openstack_odooclient import Client as OdooClient
>>> odoo_client = OdooClient(
...     hostname="localhost",
...     port=8069,
...     protocol="jsonrpc",
...     database="odoodb",
...     user="test-user",
...     password="<password>",
... )
>>> odoo_client.users.search([("id", "=", odoo_client.user_id)], as_id=True)
[1234]

For more information on the available managers and their functions, check the Managers page in the documentation.

Records

Record manager methods return record objects for the corresponding model in Odoo.

Record fields can be accessed as attributes on these record objects. The record classes are fully type hinted, allowing IDEs and validation tools such as Mypy to verify that your application is using the fields correctly.

>>> from openstack_odooclient import Client as OdooClient, User
>>> user: User | None = None
>>> odoo_client = OdooClient(
...     hostname="localhost",
...     port=8069,
...     protocol="jsonrpc",
...     database="odoodb",
...     user="test-user",
...     password="<password>",
... )
>>> user = odoo_client.users.get(1234)
>>> user
User(record={'id': 1234, ...}, fields=None)
>>> user.id
1234

For more information on the available managers and their functions, check the Records section in the documentation.

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

openstack_odooclient-0.2.6.tar.gz (158.8 kB view details)

Uploaded Source

Built Distribution

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

openstack_odooclient-0.2.6-py3-none-any.whl (94.9 kB view details)

Uploaded Python 3

File details

Details for the file openstack_odooclient-0.2.6.tar.gz.

File metadata

  • Download URL: openstack_odooclient-0.2.6.tar.gz
  • Upload date:
  • Size: 158.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.17 {"installer":{"name":"uv","version":"0.9.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for openstack_odooclient-0.2.6.tar.gz
Algorithm Hash digest
SHA256 b5dc04e215a4dc912690a7e5f6afea4cbdec7b92c2f6a10a4373da1a5f48e8b9
MD5 e980df92d0d9e0b4aaa0c4589ffca9dd
BLAKE2b-256 57ff4c14f75a480afb7d829726bf8baa86021a3307fc97c0ad14286c0f3c688f

See more details on using hashes here.

File details

Details for the file openstack_odooclient-0.2.6-py3-none-any.whl.

File metadata

  • Download URL: openstack_odooclient-0.2.6-py3-none-any.whl
  • Upload date:
  • Size: 94.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.17 {"installer":{"name":"uv","version":"0.9.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for openstack_odooclient-0.2.6-py3-none-any.whl
Algorithm Hash digest
SHA256 bc9b2a8f1712b53289f6784b66b9d68f746fa31a9919fc86c2d452f791949d72
MD5 8b4aaafefea92b73849a874680ed7c7a
BLAKE2b-256 4c5c8304d7a5b6da67f65c7cc5627bb549db775d3666308e5245e5a73dee18c7

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