Struct odoo_api::OdooClient
source · pub struct OdooClient<S, I>where
S: AuthState,
I: RequestImpl,{ /* private fields */ }
Expand description
An Odoo API client
This is the main public interface for the odoo-api
crate. It provides
methods to authenticate with an Odoo instance, and to call JSON-RPC methods
(execute
, create_database
, etc), “Web” methods (/web/session/authenticate
, etc)
and ORM methods (read_group
, create
, etc).
Usage:
use odoo_api::{OdooClient, jvec, jmap};
let url = "https://demo.odoo.com";
let mut client = OdooClient::new_reqwest_async(url)?
.authenticate(
"test-database",
"admin",
"password"
).await?;
let user_ids = client.execute(
"res.users",
"search",
jvec![
[]
]
).send().await?;
println!("Found user IDs: {:?}", user_ids.data);
Implementations§
source§impl<I: RequestImpl> OdooClient<Authed, I>
impl<I: RequestImpl> OdooClient<Authed, I>
sourcepub fn common_login(&mut self) -> OdooRequest<'_, Login, I>
pub fn common_login(&mut self) -> OdooRequest<'_, Login, I>
Check the user credentials and return the user ID
See Login
for more info.
source§impl<I: RequestImpl> OdooClient<Authed, I>
impl<I: RequestImpl> OdooClient<Authed, I>
sourcepub fn common_authenticate(
&mut self,
user_agent_env: Map<String, Value>
) -> OdooRequest<'_, Authenticate, I>
pub fn common_authenticate( &mut self, user_agent_env: Map<String, Value> ) -> OdooRequest<'_, Authenticate, I>
Check the user credentials and return the user ID (web)
See Authenticate
for more info.
source§impl<I: RequestImpl, S: AuthState> OdooClient<S, I>
impl<I: RequestImpl, S: AuthState> OdooClient<S, I>
sourcepub fn common_version(&mut self) -> OdooRequest<'_, Version, I>
pub fn common_version(&mut self) -> OdooRequest<'_, Version, I>
Fetch detailed information about the Odoo version
See Version
for more info.
source§impl<I: RequestImpl, S: AuthState> OdooClient<S, I>
impl<I: RequestImpl, S: AuthState> OdooClient<S, I>
sourcepub fn common_about(&mut self, extended: bool) -> OdooRequest<'_, About, I>
pub fn common_about(&mut self, extended: bool) -> OdooRequest<'_, About, I>
Fetch basic information about the Odoo version
See About
for more info.
source§impl<I: RequestImpl, S: AuthState> OdooClient<S, I>
impl<I: RequestImpl, S: AuthState> OdooClient<S, I>
sourcepub fn db_create_database(
&mut self,
passwd: &str,
db_name: &str,
demo: bool,
lang: &str,
user_password: &str,
login: &str,
country_code: Option<String>,
phone: Option<String>
) -> OdooRequest<'_, CreateDatabase, I>
pub fn db_create_database( &mut self, passwd: &str, db_name: &str, demo: bool, lang: &str, user_password: &str, login: &str, country_code: Option<String>, phone: Option<String> ) -> OdooRequest<'_, CreateDatabase, I>
Create and initialize a new database
See CreateDatabase
for more info.
source§impl<I: RequestImpl, S: AuthState> OdooClient<S, I>
impl<I: RequestImpl, S: AuthState> OdooClient<S, I>
sourcepub fn db_duplicate_database(
&mut self,
passwd: &str,
db_original_name: &str,
db_name: &str
) -> OdooRequest<'_, DuplicateDatabase, I>
pub fn db_duplicate_database( &mut self, passwd: &str, db_original_name: &str, db_name: &str ) -> OdooRequest<'_, DuplicateDatabase, I>
Duplicate a database
See DuplicateDatabase
for more info.
source§impl<I: RequestImpl, S: AuthState> OdooClient<S, I>
impl<I: RequestImpl, S: AuthState> OdooClient<S, I>
source§impl<I: RequestImpl, S: AuthState> OdooClient<S, I>
impl<I: RequestImpl, S: AuthState> OdooClient<S, I>
sourcepub fn db_dump(
&mut self,
passwd: &str,
db_name: &str,
format: DumpFormat
) -> OdooRequest<'_, Dump, I>
pub fn db_dump( &mut self, passwd: &str, db_name: &str, format: DumpFormat ) -> OdooRequest<'_, Dump, I>
Dump (backup) a database, optionally including the filestore folder
See Dump
for more info.
source§impl<I: RequestImpl, S: AuthState> OdooClient<S, I>
impl<I: RequestImpl, S: AuthState> OdooClient<S, I>
sourcepub fn db_restore(
&mut self,
passwd: &str,
b64_data: &str,
restore_type: RestoreType
) -> OdooRequest<'_, Restore, I>
pub fn db_restore( &mut self, passwd: &str, b64_data: &str, restore_type: RestoreType ) -> OdooRequest<'_, Restore, I>
Upload and restore an Odoo dump to a new database
See Restore
for more info.
source§impl<I: RequestImpl, S: AuthState> OdooClient<S, I>
impl<I: RequestImpl, S: AuthState> OdooClient<S, I>
source§impl<I: RequestImpl, S: AuthState> OdooClient<S, I>
impl<I: RequestImpl, S: AuthState> OdooClient<S, I>
sourcepub fn db_change_admin_password(
&mut self,
passwd: &str,
new_passwd: &str
) -> OdooRequest<'_, ChangeAdminPassword, I>
pub fn db_change_admin_password( &mut self, passwd: &str, new_passwd: &str ) -> OdooRequest<'_, ChangeAdminPassword, I>
Change the Odoo “master password”
See ChangeAdminPassword
for more info.
source§impl<I: RequestImpl, S: AuthState> OdooClient<S, I>
impl<I: RequestImpl, S: AuthState> OdooClient<S, I>
sourcepub fn db_migrate_databases(
&mut self,
passwd: &str,
databases: Vec<String>
) -> OdooRequest<'_, MigrateDatabases, I>
pub fn db_migrate_databases( &mut self, passwd: &str, databases: Vec<String> ) -> OdooRequest<'_, MigrateDatabases, I>
Perform a “database migration” (upgrade the base
module)
See MigrateDatabases
for more info.
source§impl<I: RequestImpl, S: AuthState> OdooClient<S, I>
impl<I: RequestImpl, S: AuthState> OdooClient<S, I>
source§impl<I: RequestImpl, S: AuthState> OdooClient<S, I>
impl<I: RequestImpl, S: AuthState> OdooClient<S, I>
source§impl<I: RequestImpl, S: AuthState> OdooClient<S, I>
impl<I: RequestImpl, S: AuthState> OdooClient<S, I>
sourcepub fn db_list_lang(&mut self) -> OdooRequest<'_, ListLang, I>
pub fn db_list_lang(&mut self) -> OdooRequest<'_, ListLang, I>
List the languages available to Odoo (ISO name + code)
See ListLang
for more info.
source§impl<I: RequestImpl, S: AuthState> OdooClient<S, I>
impl<I: RequestImpl, S: AuthState> OdooClient<S, I>
sourcepub fn db_list_countries(
&mut self,
passwd: &str
) -> OdooRequest<'_, ListCountries, I>
pub fn db_list_countries( &mut self, passwd: &str ) -> OdooRequest<'_, ListCountries, I>
List the countries available to Odoo (ISO name + code)
See ListCountries
for more info.
source§impl<I: RequestImpl, S: AuthState> OdooClient<S, I>
impl<I: RequestImpl, S: AuthState> OdooClient<S, I>
sourcepub fn db_server_version(&mut self) -> OdooRequest<'_, ServerVersion, I>
pub fn db_server_version(&mut self) -> OdooRequest<'_, ServerVersion, I>
Return the server version
See ServerVersion
for more info.
source§impl<I: RequestImpl> OdooClient<Authed, I>
impl<I: RequestImpl> OdooClient<Authed, I>
source§impl<I: RequestImpl> OdooClient<Authed, I>
impl<I: RequestImpl> OdooClient<Authed, I>
source§impl<I: RequestImpl> OdooClient<Authed, I>
impl<I: RequestImpl> OdooClient<Authed, I>
Create a new record (or set of records)
See Create
for more info.
pub fn create<V: Into<CreateVals>>( &mut self, model: &str, values: V ) -> OdooRequest<'_, Create, I>
source§impl<I: RequestImpl> OdooClient<Authed, I>
impl<I: RequestImpl> OdooClient<Authed, I>
Read data from a record (or set of records)
See Read
for more info.
source§impl<I: RequestImpl> OdooClient<Authed, I>
impl<I: RequestImpl> OdooClient<Authed, I>
Write data to a record (or set of records)
See Write
for more info.
source§impl<I: RequestImpl> OdooClient<Authed, I>
impl<I: RequestImpl> OdooClient<Authed, I>
Delete a record (or set of records)
See Unlink
for more info.
source§impl<I: RequestImpl> OdooClient<Authed, I>
impl<I: RequestImpl> OdooClient<Authed, I>
Read some grouped data from a record (or set of records)
See ReadGroup
for more info.
source§impl<I: RequestImpl> OdooClient<Authed, I>
impl<I: RequestImpl> OdooClient<Authed, I>
Perform a search
and read
in one call
See SearchRead
for more info.
pub fn search_read( &mut self, model: &str, domain: Vec<Value>, fields: Vec<String>, offset: Option<u32>, limit: Option<u32>, order: Option<String> ) -> OdooRequest<'_, SearchRead, I>
source§impl<I: RequestImpl> OdooClient<Authed, I>
impl<I: RequestImpl> OdooClient<Authed, I>
Return the ids of records matching a domain
See Search
for more info.
source§impl<I: RequestImpl> OdooClient<Authed, I>
impl<I: RequestImpl> OdooClient<Authed, I>
Return the count of records matching a domain
See SearchCount
for more info.
pub fn search_count( &mut self, model: &str, domain: Vec<Value>, limit: Option<u32> ) -> OdooRequest<'_, SearchCount, I>
source§impl<I: RequestImpl> OdooClient<Authed, I>
impl<I: RequestImpl> OdooClient<Authed, I>
Copy a record
See Copy
for more info.
source§impl<I: RequestImpl> OdooClient<Authed, I>
impl<I: RequestImpl> OdooClient<Authed, I>
Check if the record(s) exist in the Odoo database
See Exists
for more info.
source§impl<I: RequestImpl> OdooClient<Authed, I>
impl<I: RequestImpl> OdooClient<Authed, I>
Check model access rights (according to ir.model.access
)
See CheckAccessRights
for more info.
pub fn check_access_rights( &mut self, model: &str, operation: AccessOperation, raise_exception: bool ) -> OdooRequest<'_, CheckAccessRights, I>
source§impl<I: RequestImpl> OdooClient<Authed, I>
impl<I: RequestImpl> OdooClient<Authed, I>
Check model access rules (according to ir.rule
)
See CheckAccessRules
for more info.
pub fn check_access_rules<ID: Into<OdooIds>>( &mut self, model: &str, ids: ID, operation: AccessOperation ) -> OdooRequest<'_, CheckAccessRules, I>
source§impl<I: RequestImpl> OdooClient<Authed, I>
impl<I: RequestImpl> OdooClient<Authed, I>
Check the user access rights on the given fields
See CheckFieldAccessRights
for more info.
pub fn check_field_access_rights( &mut self, model: &str, operation: AccessOperation, fields: Vec<String> ) -> OdooRequest<'_, CheckFieldAccessRights, I>
source§impl<I: RequestImpl> OdooClient<Authed, I>
impl<I: RequestImpl> OdooClient<Authed, I>
Return some metadata about the given record(s)
See GetMetadata
for more info.
pub fn get_metadata<ID: Into<OdooIds>>( &mut self, model: &str, ids: ID ) -> OdooRequest<'_, GetMetadata, I>
source§impl<I: RequestImpl> OdooClient<Authed, I>
impl<I: RequestImpl> OdooClient<Authed, I>
Fetch the XMLID for the given record(s)
See GetExternalId
for more info.
pub fn get_external_id<ID: Into<OdooIds>>( &mut self, model: &str, ids: ID ) -> OdooRequest<'_, GetExternalId, I>
source§impl<I: RequestImpl> OdooClient<Authed, I>
impl<I: RequestImpl> OdooClient<Authed, I>
Fetch the XMLID for the given record(s)
See GetXmlId
for more info.
pub fn get_xml_id<ID: Into<OdooIds>>( &mut self, model: &str, ids: ID ) -> OdooRequest<'_, GetXmlId, I>
source§impl<I: RequestImpl> OdooClient<Authed, I>
impl<I: RequestImpl> OdooClient<Authed, I>
Fetch the display_naame
for the given record(s)
See NameGet
for more info.
source§impl<I: RequestImpl> OdooClient<Authed, I>
impl<I: RequestImpl> OdooClient<Authed, I>
Create a new record, passing only the name
field
See NameCreate
for more info.
pub fn name_create( &mut self, model: &str, name: &str ) -> OdooRequest<'_, NameCreate, I>
source§impl<I: RequestImpl> OdooClient<Authed, I>
impl<I: RequestImpl> OdooClient<Authed, I>
Search for records based on their name
field
See NameSearch
for more info.
pub fn name_search( &mut self, model: &str, name: &str, args: Option<Vec<Value>>, operator: Option<String>, limit: Option<u32> ) -> OdooRequest<'_, NameSearch, I>
source§impl<I: RequestImpl, S: AuthState> OdooClient<S, I>
impl<I: RequestImpl, S: AuthState> OdooClient<S, I>
Authenticate to an Odoo database
See SessionAuthenticate
for more info.
pub fn web_session_authenticate( &mut self, db: &str, login: &str, password: &str ) -> OdooRequest<'_, SessionAuthenticate, I>
source§impl<I: RequestImpl, S: AuthState> OdooClient<S, I>
impl<I: RequestImpl, S: AuthState> OdooClient<S, I>
List the available databases
See DatabaseList
for more info.
pub fn web_database_list(&mut self) -> OdooRequest<'_, DatabaseList, I>
source§impl<I: RequestImpl, S: AuthState> OdooClient<S, I>
impl<I: RequestImpl, S: AuthState> OdooClient<S, I>
Fetch session information
See GetSessionInfo
for more info.