| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
The odoo-api odoo-api is a Rust library crate that provides a user-friendly interface to interact with the Odoo JSONRPC and ORM APIs, while preserving strong typing. It includes both async and blocking support out of the box, and allows users to provide their own implementations if needed.
See the Example section below for a brief example, or the client module for more in-depth examples.
See the service module for a full list of supported API methods.
Do you already have an HTTP library in your dependencies (e.g., reqwest)?
The odoo-api crate allows you to use your existing HTTP library by writing a simple shim closure. See client::ClosureAsync or client::ClosureBlocking for more info.
The crate offers a types-only feature. When enabled, the library only exposes the API request & response types, along with Serialize and Deserialize impls. The async/blocking impls (and the reqwest dependency) are dropped when this feature is active.
See the jsonrpc module for information on types-only.
[dependencies]
odoo_api = "0.2"Then make your requests:
use odoo_api::{OdooClient, jvec, jmap};
// build the client
let url = "https://odoo.example.com";
let mut client = OdooClient::new_reqwest_async(url)?;
// authenticate with `some-database`
let mut client = client.authenticate(
"some-database",
"admin",
"password",
).await?;
// fetch a list of users with the `execute` method
let users = client.execute(
"res.users",
"search",
jvec![]
).send().await?;
// fetch the login and partner_id fields from user id=1
let info = client.execute_kw(
"res.users",
"read",
jvec![[1]],
jmap!{
"fields": ["login", "partner_id"]
}
).send().await?;
// create 2 new partners with the `create` ORM method
let partners = client.create(
"res.partner",
jvec![{
"name": "Alice",
"email": "alice@example.com",
"phone": "555-555-5555",
}, {
"name": "Bob",
"email": "bob@example.com",
"phone": "555-555-5555",
}]
).send().await?;
// fetch a list of databases
let databases = client.db_list(false).send().await?;
// fetch server version info
let version_info = client.common_version().send().await?;| Back | FazBrowse Home | New Git URL |