Odoo Component
Manage records in an Odoo database
Component key: odooDescription
Odoo is a suite of open source business apps that include CRM, eCommerce, accounting, inventory, project management, etc. This component allows you to query and manage records in an Odoo database.
Developer Note: Odoo Models
An Odoo database tracks hundreds of types of records. A default installation of Odoo includes more than 800 unique record types (more if you install additional apps).
Each type of record is called a model, and models have human-readable names and model names.
For example, contacts in Odoo are called Contacts
, and their model name is res.partner
.
To list all contacts in an Odoo installation, use the List Records action and provide it a model of res.partner
.
A model has fields.
Contacts
for example has hundreds of fields related to a person: name
, email
, country_code
, zip
, etc.
For your convenience, two utility actions are included in this component.
- List Models will list all models in an Odoo installation, including their ID, name and model name.
- List Model Fields will list all of the fields of a given model.
You can use these two utility actions to help you when you Create or Update records. Identify the name of the fields you would like to set for a given model. Then, create an object, either in a code step or another action and pass the results of that step in as a reference.
Connections
Odoo Connection
Customers can use Odoo's cloud service to access an Odoo database, or they can run Odoo on their own servers. Either way, Odoo uses basic auth to connect to an Odoo database.
- For Base URL, you can enter the URL you visit when you log in to Odoo (something like
https://example-company.odoo.com
). - You can likely ignore Server Port, unless your customer uses a non-traditional port for accessing their Odoo installation.
- The Database Name can be found by clicking the user icon on the top-right within Odoo, and then selecting My Databases.
- Username is the email address the user uses to log in. We recommend they create a system account for integrations (i.e. not a specific user's account).
- Password or API Key can either be the password your customer uses to log in to Odoo, or they can generate an API key. To generate an API key, your customer will need to go into settings, enable developer mode, and then from their user preferences they can generate an API key. See https://www.odoo.com/documentation/14.0/developer/api/external_api.html#api-keys.
Actions
Create Record
Create a new record of a given type | key: createRecord
{
"data": 25
}
Delete Record By ID
Delete a record by its numerical ID | key: deleteRecordById
{
"data": true
}
Get Record by External ID
Get a record by its external ID | key: getRecordByExternalId
{
"data": {
"id": 12,
"website_url": "/partners/john-doe-12",
"email": "bob@example.com",
"name": "John Doe",
"display_name": "John Doe",
"lang": "en_US"
}
}
Get Record By ID
Fetch a Record by its numerical ID | key: getRecordById
{
"data": {
"id": 12,
"website_url": "/partners/john-doe-12",
"email": "bob@example.com",
"name": "John Doe",
"display_name": "John Doe",
"lang": "en_US"
}
}
List Model Fields
List all fields for a given model | key: listModelFields
{
"data": {
"is_seo_optimized": {
"type": "boolean",
"change_default": false,
"company_dependent": false,
"depends": [],
"manual": false,
"readonly": true,
"required": false,
"searchable": false,
"sortable": false,
"store": false,
"string": "SEO optimized",
"name": "is_seo_optimized"
},
"website_meta_title": {
"type": "char",
"change_default": false,
"company_dependent": false,
"depends": [],
"manual": false,
"readonly": false,
"required": false,
"searchable": true,
"sortable": true,
"store": true,
"string": "Website meta title",
"translate": true,
"trim": true,
"name": "website_meta_title"
}
}
}
List Models
Fetch a list of models installed in the customer's Odoo database | key: listModels
{
"data": [
{
"id": 87,
"name": "Bank Accounts",
"model": "res.partner.bank",
"state": "base",
"modules": "account, base, l10n_us",
"display_name": "Bank Accounts"
},
{
"id": 85,
"name": "Industry",
"model": "res.partner.industry",
"state": "base",
"modules": "base",
"display_name": "Industry"
}
]
}
List Records
Fetch a list of records of a given type | key: listRecords
If you expect Odoo will return lots of records, you can leverage pagination to process a small set of records at a time. See Odoo's docs on pagination.
{
"data": [
{
"id": 12,
"website_url": "/partners/john-doe-12",
"email": "bob@example.com",
"name": "John Doe",
"display_name": "John Doe",
"lang": "en_US"
}
]
}
Raw Request
Issue any execute_kw action | key: rawRequest
Set External ID
Add an external ID to a record that does not have one | key: setExternalId
{
"data": 21943
}
Update Record
Update an existing record of a given type | key: updateRecord
{
"data": true
}