Lightweight Python wrapper for the Odoo XML-RPC API
Project description
odoo-easy
A lightweight Python wrapper for the Odoo XML-RPC API. Stop writing boilerplate — connect and query Odoo in 3 lines.
Installation
pip install odoo-easy
Quick Start
from odoo_connect import OdooClient
odoo = OdooClient("https://mycompany.odoo.com", "my-database")
odoo.login("admin@example.com", "your-password")
# List products
products = odoo.search_read("product.template", fields=["name", "list_price"])
Usage
Connect
from odoo_connect import OdooClient
odoo = OdooClient("https://mycompany.odoo.com", "my-database")
odoo.login("admin@example.com", "your-password")
Search records
# Get all IDs
ids = odoo.search("product.template")
# With filters
ids = odoo.search("product.template", filters=[["type", "=", "product"]])
# With limit
ids = odoo.search("product.template", limit=10)
Search and read in one call
products = odoo.search_read(
"product.template",
filters=[["sale_ok", "=", True]],
fields=["name", "list_price", "categ_id"],
limit=50
)
# Returns: [{"id": 1, "name": "My Product", "list_price": 99.0, ...}, ...]
Read by IDs
records = odoo.read("res.partner", ids=[1, 2, 3], fields=["name", "email"])
Create a record
new_id = odoo.create("product.template", {
"name": "New Product",
"list_price": 49.99,
"type": "product",
})
print(f"Created product with ID: {new_id}")
Update records
odoo.write("product.template", ids=[1, 2, 3], values={
"list_price": 59.99
})
Delete records
odoo.unlink("product.template", ids=[99])
Count records
total = odoo.count("product.template", filters=[["active", "=", True]])
print(f"Total active products: {total}")
Inspect model fields
fields = odoo.get_fields("product.template", attributes=["string", "type"])
Get server version
info = odoo.version()
print(info) # {'server_version': '18.0', ...}
Error Handling
from odoo_connect import OdooClient, OdooAuthError, OdooError
try:
odoo = OdooClient("https://mycompany.odoo.com", "my-database")
odoo.login("wrong@example.com", "badpassword")
except OdooAuthError as e:
print(f"Authentication failed: {e}")
except OdooError as e:
print(f"Odoo error: {e}")
Compatibility
- Python 3.8+
- Odoo 14, 15, 16, 17, 18
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
odoo_easy-0.1.0.tar.gz
(4.7 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file odoo_easy-0.1.0.tar.gz.
File metadata
- Download URL: odoo_easy-0.1.0.tar.gz
- Upload date:
- Size: 4.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d3246a31c37017b3ece31af382f7519cd3786a094c95548aa517747cededd947
|
|
| MD5 |
6f187d0fe58fe25a7eaa27106d563d20
|
|
| BLAKE2b-256 |
e44b43ee4426398af819c6d1d3804d9b6417c652d58180ce06a95539822670cd
|
File details
Details for the file odoo_easy-0.1.0-py3-none-any.whl.
File metadata
- Download URL: odoo_easy-0.1.0-py3-none-any.whl
- Upload date:
- Size: 5.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1bb754a7e48ceafddd986cd54ac8a34f97051141bfcc508f68d55c5d0bfb7c14
|
|
| MD5 |
833ce133d321e6742dfa09c2a5750b31
|
|
| BLAKE2b-256 |
aac9ba772e747a161562cafb81dbb784d7a493c33557a550891005ef33f8aab4
|