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.
Once: API key and connector
Section titled “Once: API key and connector”- In Odoo: click your name at the top right → My Profile → Account Security → New API Key. Copy the key; Odoo shows it only once.
- In RUNOS: Connectors → New → Blank connector. Name
Odoo, Base URLhttps://yourcompany.odoo.com, auth type API key, paste the key, HeaderAuthorization, SchemeBearer. Save. - If there are several databases on one server, enter the database under Advanced → Extra JSON:
{ "Database": "yourcompany" }.
More under ApiKey.
Search contacts
Section titled “Search contacts”{ "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 } }}domainis 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.
Create a contact if it is missing
Section titled “Create a contact if it is missing”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}}.
The whole workflow
Section titled “The whole workflow”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 */ } } ]}