pub struct Execute {
pub database: String,
pub uid: OdooId,
pub password: String,
pub model: String,
pub method: String,
pub args: Vec<Value>,
}
Expand description
Call a business-logic method on an Odoo model (positional args)
This method 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.
Note that the way this method handles keyword argument is unintuitive. If
you need to send kwargs
to an Odoo method, you should use ExecuteKw
instead
§Example
use odoo_api::jvec;
// read `id` and `login` from users id=1,2,3
client.execute(
"res.users",
"read",
jvec![
[1, 2, 3],
["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
The arguments are passed to Python as object.method_name(*args)
, so
kwargs are technically supported here.
For example, consider the Python function
def search_read(domain, fields=None):
pass
Our args
field should be structured like:
let args = jvec![
// element #1 goes to `domain`
[
["name", "!=", "admin"],
],
// element #2 goes to `fields`
["id", "login"]
];
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.
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 method arguments
Trait Implementations§
Source§impl JsonRpcParams for Execute
impl JsonRpcParams for Execute
type Container<T> = OdooApiContainer<Execute>
type Response = ExecuteResponse
fn build(self, id: JsonRpcId) -> JsonRpcRequest<Self>
Source§impl OdooApiMethod for Execute
impl OdooApiMethod for Execute
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