Skip to content

Odoo Contacts

Odoo stores contacts (customers, vendors, contact persons) in the res.partner model. From Odoo 19 on, Odoo offers the JSON-2 API for this: every method of a model is an address /json/2/<model>/<method>, and you sign in with an API key.

  1. In Odoo: click your name at the top right → My Profile → Account Security → New API Key. Copy the key; Odoo shows it only once.
  2. In RUNOS: Connectors → New → Blank connector. Name Odoo, Base URL https://yourcompany.odoo.com, auth type API key, paste the key, Header Authorization, Scheme Bearer. Save.
  3. If there are several databases on one server, enter the database under Advanced → Extra JSON: { "Database": "yourcompany" }.

More under ApiKey.

{
"Type": "HttpRequest",
"Name": "FindContact",
"Parameters": {
"Url": "/json/2/res.partner/search_read",
"Method": "POST",
"Connector": "Odoo",
"Headers": { "X-Odoo-Database": "{{connector.Odoo.ExtraJson.Database}}" },
"Body": {
"domain": [ [ "email", "=ilike", "{{InitialData.Email}}" ] ],
"fields": [ "name", "email", "phone", "company_name" ],
"limit": 5
}
}
}
  • domain is Odoo’s search filter: a list of conditions [field, operator, value], e.g. ["is_company", "=", true] or ["name", "ilike", "Muster"].
  • The response is a list of the contacts found. Read the first hit with {{FindContact.Response.Body.0.name}}, the count with {{FindContact.Response.Body.count}}.
  • Without X-Odoo-Database (only one database), the header stays empty and is not sent.

Together with IF: the contact is created only if the search found nothing.

{
"Type": "If",
"Name": "NewContact",
"Parameters": {
"Condition": "{{FindContact.Response.Body.count}} == 0",
"Do": [
{
"Type": "HttpRequest",
"Name": "CreateContact",
"Parameters": {
"Url": "/json/2/res.partner/create",
"Method": "POST",
"Connector": "Odoo",
"Headers": { "X-Odoo-Database": "{{connector.Odoo.ExtraJson.Database}}" },
"Body": {
"vals_list": [
{
"name": "{{InitialData.Name}}",
"email": "{{InitialData.Email}}",
"phone": "{{InitialData.Phone}}",
"is_company": false
}
]
}
}
}
]
}
}

Odoo answers with the list of new IDs, e.g. [42]; the ID is in {{CreateContact.Response.Body.0}}.

A web form or another program puts a small JSON file with a script block into the folder C:\RUNOS\Contacts:

#RUNOS {"InitialData":{"Name":"Erika Muster","Email":"erika@example.com","Phone":"+49 30 1234567"}} #RUNOS
{
"Name": "Contacts to Odoo",
"Autostart": true,
"Trigger": {
"Type": "File",
"Name": "Inbox",
"Parameters": { "Pool": "C:\\RUNOS\\Contacts", "Filter": "*.json", "DeleteAfter": true }
},
"Actions": [
{ "Type": "HttpRequest", "Name": "FindContact", "Parameters": { /* as above */ } },
{ "Type": "If", "Name": "NewContact", "Parameters": { /* as above */ } }
]
}