pub struct ExecuteKw {
pub database: String,
pub uid: OdooId,
pub password: String,
pub model: String,
pub method: String,
pub args: Vec<Value>,
pub kwargs: Map<String, Value>,
}
Expand description
Call a business-logic method on an Odoo model (positional & keyword args)
This method is very similar to execute
; It allows you to call an arbitrary
Odoo method (e.g. read
or create
or my_function
), passing some arbitrary
data, and returns the result of that method call.
This differs from execute
in that keyword args (kwargs
) can be passed.
§Execute:
use odoo_api::{jvec, jmap};
// read `id` and `login` from any user whose email matches "%@example.com"
client.execute_kw(
"res.users",
"search_read",
jvec![
[["login", "=ilike", "%@example.com"]]
],
jmap!{
"fields": ["id", "login"]
}
).send()?;
§Arguments
§method
The method
field indicates the Python function to be called. This can be
any non-private method. Methods starting with an underscore (e.g. _onchange_name
)
are considered to be “private”.
§args
and kwargs
The method args (position and keyword) are passed to Python as (*args, **kwargs)
.
For example:
## this function...
def search_read(self, domain, fields=None):
pass
## ...would be called like
model.search_read(*args, **kwargs)
This is much simpler than Execute
.
Also note that many Odoo methods accept self
as the first param. In that
case, you should pass a list of IDs as the first element.
Reference: odoo/service/model.py
Fields§
§database: String
The database name (auto-filled by OdooClient
)
uid: OdooId
The user id (auto-filled by OdooClient
)
password: String
The user password (auto-filled by OdooClient
)
model: String
The model name
method: String
The method name
args: Vec<Value>
The positional arguments
kwargs: Map<String, Value>
The keyword argments
Trait Implementations§
Source§impl JsonRpcParams for ExecuteKw
impl JsonRpcParams for ExecuteKw
type Container<T> = OdooApiContainer<ExecuteKw>
type Response = ExecuteKwResponse
fn build(self, id: JsonRpcId) -> JsonRpcRequest<Self>
Source§impl OdooApiMethod for ExecuteKw
impl OdooApiMethod for ExecuteKw
Source§fn describe(&self) -> (&'static str, &'static str)
fn describe(&self) -> (&'static str, &'static str)
Source§fn endpoint(&self) -> &'static str
fn endpoint(&self) -> &'static str
Source§fn _build(self, id: JsonRpcId) -> JsonRpcRequest<Self>
fn _build(self, id: JsonRpcId) -> JsonRpcRequest<Self>
self
into a full JsonRpcRequest