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

Important Version Guidance

pyodoo-client is for Odoo JSON-2 (/json/2) workflows (Odoo 19+).

If your project targets older Odoo versions that still use the classic RPC style, use pyodoo-rpc-client instead:

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

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.3.tar.gz (11.8 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.3-py3-none-any.whl (10.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pyodoo_client-19.0.3.tar.gz
  • Upload date:
  • Size: 11.8 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.3.tar.gz
Algorithm Hash digest
SHA256 a30f594ff80342a233486c3858a3180f94ebb5252410b49bce65c61fbfae371e
MD5 8c957783be74209a845fbb8e2e6bdf50
BLAKE2b-256 50ba4d10728aea5ebfcf7964457031febb973cf6f0ed461be7a98ab8463a8cc8

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pyodoo_client-19.0.3-py3-none-any.whl
  • Upload date:
  • Size: 10.4 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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 9dea53e382938803b38ff32e94c23f42db7f1475e57b31a3383da5294dbd704b
MD5 14bb81526623042b36db17946dcb22e0
BLAKE2b-256 d33aff5084cc2c7ccc7f3961cf35135a245661565774c2ff9cfa4767e4a4dabf

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