Skip to main content

Odoo JSON-2 API client for Odoo 19+

Project description

pyodoo-client (Odoo 19+ JSON-2)

Python client for Odoo JSON-2 API (/json/2) targeting Odoo 19+.

Features

  • JSON-2 model calls with named payloads.
  • ORM-like model access (client.model("res.partner")).
  • OdooEntity convenience wrapper (save, delete, refresh).
  • Context layering (default_context, with_context, per-call context).
  • Runtime debug mode toggle:
    • debug=False: returns safe defaults and stores errors.
    • debug=True: raises exceptions.
  • Database service wrappers for /web/version and /web/database/*.

Installation

pip install pyodoo-client

Quick Start

from pyodoo_client import OdooClient

odoo = OdooClient(
    url="https://mycompany.example.com",
    db="mycompany",
    api_key="YOUR_API_KEY",
    debug=False,
)

partners = odoo.model("res.partner").search_read({
    "context": {"lang": "en_US"},
    "domain": [
        ["name", "ilike", "%deco%"],
        ["is_company", "=", True],
    ],
    "fields": ["name"],
})

API Overview

OdooClient

  • OdooClient(url, api_key=None, key=None, db=None, timeout=30, verify_ssl=True, user_agent="pyodoo-client", debug=False, default_context=None)
  • model(model_name)
  • set_debug(bool)
  • set_default_context(dict) / update_default_context(dict)
  • call_model(model_name, method, payload=None, context=None, debug=None, default=None)
  • call_web(method, path, ...)
  • database service property

OdooModel

  • with_context(context=None, **kwargs)
  • with_company(company) (alias for setting company context)
  • set_debug(bool)
  • execute(method, *args, **kwargs)
  • CRUD helpers: search, search_read, read, create, write, unlink, fields_get

Context helpers:

partners = odoo.model("res.partner")

# Dict style
partners_en = partners.with_context({"lang": "en_US", "tz": "UTC"})

# Kwargs style (equivalent)
partners_fr = partners.with_context(lang="fr_FR", tz="Europe/Paris")

# Company alias (maps to context keys)
partners_c7 = partners.with_company(7)
# -> context includes: {"allowed_company_ids": [7], "company_id": 7}

OdooEntity

  • id, exists(), refresh()
  • get_data(fields=None)
  • save(), delete()

Compatibility Notes

  • For common ORM methods, limited positional compatibility is provided.
  • For custom methods, use named dict payloads:
model = odoo.model("your.model")
result = model.your_method({"param_a": 1, "param_b": "x"})

JSON-2 does not support positional arguments for method parameters.

Database Service

version = odoo.database.version()
dbs = odoo.database.list()
exists = odoo.database.db_exist("mycompany")

Includes wrappers:

  • version, server_version, list, db_exist
  • create_database, duplicate_database, drop
  • change_admin_password, backup, restore, neutralize_database

Error Handling

  • Last error available on client.error or model.error.
  • Set debug=True to raise exceptions immediately.

Supported Odoo Range

  • Intended for Odoo 19+ using JSON-2 API.
  • RPC deprecation in Odoo 20 is accounted for by using /json/2 transport.

Contributing

  • Open Issues for bugs and concrete feature requests.
  • Open Pull Requests for code/docs improvements.
  • For open-ended questions and ideas, use GitHub Discussions (enable in repo settings).
  • See CONTRIBUTING.md for workflow and expectations.

Development

python -m pip install --upgrade build twine
python -m build
python -m twine check dist/*

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

pyodoo_client-19.0.2.tar.gz (11.0 kB view details)

Uploaded Source

Built Distribution

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

pyodoo_client-19.0.2-py3-none-any.whl (10.1 kB view details)

Uploaded Python 3

File details

Details for the file pyodoo_client-19.0.2.tar.gz.

File metadata

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

File hashes

Hashes for pyodoo_client-19.0.2.tar.gz
Algorithm Hash digest
SHA256 08be69c58424cc3608c107f09c2da6e0b2bc6ac2a2451b70c7e6bad6cd8b3d81
MD5 2f4c7c2f92f34061cb364a841ddc07aa
BLAKE2b-256 3a0b51bb63051a6101a352d139549395dd77476b1a49196006e272b96401d7c1

See more details on using hashes here.

File details

Details for the file pyodoo_client-19.0.2-py3-none-any.whl.

File metadata

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

File hashes

Hashes for pyodoo_client-19.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 4d30fff72848cf2108a27e9aca35d17aaf7f357998882f2f1f05d0b7e02eec86
MD5 76212cc85b3c9c25762e18f284b1ea6e
BLAKE2b-256 74a888f5638a1bbfbc650a01ef07969af148da04a2301b1eef88c5d5526377fa

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