odoo@2.1.1
- create(model, data, options)
- deleteRecord(model, recordId)
- read(model, recordId, fields)
- searchReadRecord(model, domain, fields, [options])
- searchRecord(model, domain)
- update(model, recordId, data)
This adaptor exports the following from common:
Functions
create
create(model, data, options) ⇒ Operation
Create a record in Odoo. You can pass an external ID to the options object to create a record with a specific ID. You can also pass a downloadNewRecord option to download the whole created resource in the response.
Param | Type | Description |
---|---|---|
model | string | The specific record model i.e. "res.partner" |
data | object | The data to be created in JSON. |
options | CreateOptions | Options to send to the request. |
This operation writes the following keys to state:
State Key | Description |
---|---|
data | The response body (as JSON) |
response | The HTTP response from the Odoo server (excluding the body) |
references | An array of all previous data objects used in the Job |
Example: Create a partner record with an external Id
create('res.partner', { name: 'Kool Keith' }, { externalId: 23 });
Example: Create a partner record and download the whole record in the response
create('res.partner', { name: 'Kool Keith' }, { downloadNewRecord: true });
deleteRecord
deleteRecord(model, recordId) ⇒ Operation
Delete a record from Odoo
Param | Type | Description |
---|---|---|
model | string | The specific record model i.e. "res.partner" |
recordId | number | The specific recordId to be deleted. |
This operation writes the following keys to state:
State Key | Description |
---|---|
data | The response body (as JSON) |
response | The HTTP response from the Odoo server (excluding the body) |
references | An array of all previous data objects used in the Job |
Example
deleteRecord("res.partner", 54 );
read
read(model, recordId, fields) ⇒ Operation
Get a record from Odoo. Returns all fields unless a field list is provided as a third argument
Param | Type | Description |
---|---|---|
model | string | The specific record model from i.e. "res.partner" |
recordId | number | An array of record IDs to read. |
fields | Array.<string> | An optional array of field strings to read from the record. |
This operation writes the following keys to state:
State Key | Description |
---|---|
data | The response body (as JSON) |
response | The HTTP response from the Odoo server (excluding the body) |
references | An array of all previous data objects used in the Job |
Example: Download records with select fields
read("res.partner", [1] , ['name']);
Example: Download a single record with all fields
read("res.partner", $.recordIds);
searchReadRecord
searchReadRecord(model, domain, fields, [options]) ⇒ Operation
Search and a read record from Odoo. It returns the records that match the search criteria, with the specified fields or full records if no fields are given.
Param | Type | Default | Description |
---|---|---|---|
model | string | The specific record model i.e. "res.partner" | |
domain | object | Optional search domain to filter records. | |
fields | Array.<string> | An optional array of field strings to read from the record. i.e ['name', 'state_id'] | |
[options] | object | {} | Additional options to configure the search. |
[options.limit] | number | 1000 | Maximum number of records to fetch. If undefined, defaults to 1000, and all records available will be fetched. |
[options.offset] | number | 0 | The index of the first record to return. |
[options.pageSize] | number | 200 | The number of records to fetch in each request. Defaults to 200. |
This operation writes the following keys to state:
State Key | Description |
---|---|
data | The response body (as JSON) |
response | The HTTP response from the Odoo server (excluding the body) |
references | An array of all previous data objects used in the Job |
Example: Search and read a record with a domain filter
searchReadRecord('res.partner', {
country_id: 'United States',
});
Example: Search and read a record with specific fields
searchReadRecord(
'res.partner',
{
is_company: true,
},
['name']
);
Example: Fetch records with a limit
searchReadRecord('res.partner', {}, [], {
limit: 200,
});
searchRecord
searchRecord(model, domain) ⇒ Operation
Search a record from Odoo. Only returns record IDs. Use searchReadRecord
to download full
records which match the criteria.
Param | Type | Description |
---|---|---|
model | string | The specific record model i.e. "res.partner" |
domain | object | Optional search domain to filter records. |
This operation writes the following keys to state:
State Key | Description |
---|---|
data | An array of matching record IDs |
response | The HTTP response from the Odoo server (excluding the body) |
references | An array of all previous data objects used in the Job |
Example
searchRecord('res.partner', {
country_id: 'United States',
});
update
update(model, recordId, data) ⇒ Operation
Update a record in Odoo
Param | Type | Description |
---|---|---|
model | string | The specific record model i.e. "res.partner" |
recordId | number | The specific recordId to be updated. |
data | object | The data to be updated in JSON. |
This operation writes the following keys to state:
State Key | Description |
---|---|
data | The response body (as JSON) |
response | The HTTP response from the Odoo server (excluding the body) |
references | An array of all previous data objects used in the Job |
Example
update("res.partner", 54 , {name: 'Jane Doe'});
Interfaces
CreateOptions
Options object
Properties
Name | Type | Description |
---|---|---|
externalId | number | An optional id to be used in the request |
downloadNewRecord | boolean | An option defaulted to false incase a user intends to receive the whole created resource in the response. The collective response will be written in state.data . |
SearchOptions
Options object
Properties
Name | Type | Description |
---|---|---|
limit | number | Limit the number of records to return |
offset | number | Set to the number of records to skip |
order | string | Order to sort the records by. i.e "name, desc" |
context | object | Context to be used in the request. i.e {lang: 'en_US', timezone: 'UTC'} . |