Package ch.helvethink.odoo4java.xmlrpc
Class OdooClient
java.lang.Object
ch.helvethink.odoo4java.xmlrpc.OdooClient
- All Implemented Interfaces:
OdooRpcClient
Abstraction of Odoo's XML-RPC API
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionOdooClient(OdooXmlRpcClient commonClient, String instanceUrl, String dbName, String username, String password, boolean mustConnect) Constructor with all fieldsOdooClient(String instanceUrl, String dbName, String username, String password) Constructor with direct connectionOdooClient(String instanceUrl, String dbName, String username, String password, boolean mustConnect) Constructor that initializes the Common API XML-RPC client -
Method Summary
Modifier and TypeMethodDescriptionintcountByCriteria(Class<? extends OdooObj> objectType, String... criteria) findByCriteria(int limit, int page, Class<T> classToConvert, String... criteria) findByCriteria(int limit, int page, String sortByField, Class<T> classToConvert, String... criteria) findByCriteria(int limit, Class<T> classToConvert, String... criteria) findByNames(Class<T> classToConvert, List<String> names) Find a list of object from namesfindListByIds(List<OdooId> idsToFetch, Class<T> classToConvert) findListByIdsInt(List<Integer> idsToFetch, Class<T> classToConvert) <T extends OdooObj>
TfindObjectById(OdooId idToFetch, Class<T> classToConvert) getAllModels(String packageName) Retrieve all Odoo models of the Odoo instance we're connected toGet fields From Odoo, for a given modelRetrieve Version from the Odoo Server
-
Field Details
-
LOG
public static final org.slf4j.Logger LOGSimple logger
-
-
Constructor Details
-
OdooClient
public OdooClient(String instanceUrl, String dbName, String username, String password) throws MalformedURLException, org.apache.xmlrpc.XmlRpcException Constructor with direct connection- Parameters:
instanceUrl- The odoo Instance URLdbName- The odoo DB Nameusername- The Odoo username when authenticatingpassword- The Odoo password when authenticating- Throws:
MalformedURLException- when URI is not validorg.apache.xmlrpc.XmlRpcException- when an error occurs with the XML-RPC API
-
OdooClient
public OdooClient(String instanceUrl, String dbName, String username, String password, boolean mustConnect) throws MalformedURLException Constructor that initializes the Common API XML-RPC client- Parameters:
instanceUrl- The odoo Instance URLdbName- The odoo DB Nameusername- The Odoo username when authenticatingpassword- The Odoo password when authenticatingmustConnect- - describes if we must try to connect or not- Throws:
MalformedURLException- when URI is not valid
-
OdooClient
public OdooClient(OdooXmlRpcClient commonClient, String instanceUrl, String dbName, String username, String password, boolean mustConnect) throws MalformedURLException Constructor with all fields- Parameters:
commonClient- - The common XML-RPC API clientinstanceUrl- The odoo Instance URLdbName- The odoo DB Nameusername- The Odoo username when authenticatingpassword- The Odoo password when authenticatingmustConnect- - describes if we must try to connect or not- Throws:
MalformedURLException- when URI is not valid
-
-
Method Details
-
getVersion
Retrieve Version from the Odoo Server- Returns:
- Version like "17.0"
-
getAllModels
public List<Map<String,Object>> getAllModels(String packageName) throws org.apache.xmlrpc.XmlRpcException Retrieve all Odoo models of the Odoo instance we're connected to- Parameters:
packageName- - allows to filter the names of models we want to retrieve- Returns:
- List of Odoo models with fields like "description", "name", "access_ids", ...
- Throws:
org.apache.xmlrpc.XmlRpcException- when an error occurs with the XML-RPC API
-
getFields
public Map<String,Map<String, getFieldsObject>> (String modelName) throws org.apache.xmlrpc.XmlRpcException Get fields From Odoo, for a given model- Parameters:
modelName- The model we want to inspect- Returns:
- The list of fields as a Map containing the following information: string, help, type, and relation
- Throws:
org.apache.xmlrpc.XmlRpcException- when an error occurs with the XML-RPC API
-
findByNames
Find a list of object from names- Type Parameters:
T- The type of objects to return- Parameters:
classToConvert- The type of objectsnames- The "name" value of objects we're looking for- Returns:
- List of found objects
-
findByCriteria
public <T extends OdooObj> List<T> findByCriteria(int limit, Class<T> classToConvert, String... criteria) - Specified by:
findByCriteriain interfaceOdooRpcClient
-
findByCriteria
public <T extends OdooObj> List<T> findByCriteria(int limit, int page, Class<T> classToConvert, String... criteria) - Specified by:
findByCriteriain interfaceOdooRpcClient
-
countByCriteria
- Specified by:
countByCriteriain interfaceOdooRpcClient
-
findByCriteria
public <T extends OdooObj> List<T> findByCriteria(int limit, int page, String sortByField, Class<T> classToConvert, String... criteria) - Specified by:
findByCriteriain interfaceOdooRpcClient
-
findObjectById
- Specified by:
findObjectByIdin interfaceOdooRpcClient
-
findListByIdsInt
public <T extends OdooObj> List<T> findListByIdsInt(List<Integer> idsToFetch, Class<T> classToConvert) - Specified by:
findListByIdsIntin interfaceOdooRpcClient
-
findListByIds
- Specified by:
findListByIdsin interfaceOdooRpcClient
-