Send your Odoo records to any system, over HTTP.
Turn a server action into a webhook: pick the method, the URL and the sign-in, shape the body in Python and act on the answer. Fire it from a button, an automation rule or a schedule, and find every request in the log.
GET, POST, PUT, DELETE or a verb of your own, signed in with Basic, Digest, a Bearer token or OAuth2.
Adapt the URL, the headers and the body, then act on the response or on the error.
Right away, after the commit or from a queue that retries, and every exchange kept with its credentials masked.
A webhook is a server action
So it runs wherever a server action runs, and it is set up in a form, not in a module. Odoo's own webhook posts the fields you pick, once, with no sign-in; this one lets you choose every part of the call.
Any HTTP method, a timeout, SSL verification, header lines, and one request per record or one for all of them.
Basic, Digest, a Bearer token, or OAuth2 with the password or client-credentials grant, shared by every webhook that uses it.
Adapt the URL, the headers and the payload, JSON or XML, then process the response and handle the error.
Send in the transaction, once it has committed, or from a queue that retries with a growing pause between attempts.
The request and the response as they were sent, with a traffic graph, a pivot per webhook and a Resend button.
A URL that resolves to a private or internal address is refused, OAuth2 token URLs included, until the server config allows it.
Three hooks on one webhook
Each hook is a few lines of Python with record, env, json and etree at hand, and the Help tab of the form lists the rest. This one builds its URL from the record, sends a body of its own and writes the answer back. Assign content instead of payload to add to the default body rather than replace it.
# 01 Adapt URL: build the address from the record >>> request_url = '%s/%s' % (action_url, record.ref) POST https://warehouse.example.com/api/v2/customers/C-00010 # 02 Adapt payload: send a body of your own >>> payload = {'event': 'customer.updated', 'name': record.name, 'country': record.country_id.code} {"event": "customer.updated", "name": "Acme Corporation", "country": "US"} # 03 Process response: write the answer back to the record >>> record.write({'comment': 'Warehouse: %s' % response.json()['warehouse_ref']}) 201 Created → Acme Corporation, Warehouse: WH-2026-0412
Every exchange, on the record
Each request is stored with its URL, headers and payload, the request and the response exactly as they went over the wire, the result of your code, and the exception with its traceback when one was raised. Authorization, cookie and API-key headers are masked before anything is saved.
A failed request is sent again from its log entry. Traffic charts the requests per day, Hooks breaks them down by webhook, week and state, and old entries are cleaned up after the number of days you set.
Sign in once, use it everywhere
An authentication is a record of its own: Basic, Digest or a Bearer token, or OAuth2 with the password or the client-credentials grant, a token URL and whatever extra parameters the provider wants in the token request.
Any number of webhooks point at it, and its Webhooks button lists them. Rotate a secret in one place and every one of them signs in with the new one.
Try it before it goes live
Preview runs a webhook on a record you pick and shows the headers, the payload and the request it would send, without sending anything.
Switch on Send Request to call the endpoint and read its response and your code's result. Keep Reset Changes on and whatever that code wrote to the database is rolled back when the preview ends.
From a button, a rule or a clock
Put a webhook in the Actions menu of a record, run it from an automation rule when records are created, edited or deleted, or on a schedule. Actions, Automation and Schedules each have a menu under Webhooks that opens the webhook form directly.
The import dialog gains a Run webhooks during import checkbox, off by default, so loading a thousand rows does not send a thousand calls. A test import never sends.
Built to be extended
What a webhook does not do out of the box, a module of yours can add — on the same log, the same hooks and the same preview.
Add a value to Send Type and a _webhook_send_request_on_<type> method on ir.actions.server, and the request is yours to deliver.
Extend _authentication_selection and _prepare_session to hand back a session that signs the way your target expects.
Webhooks call out when something happens in Odoo. For other systems to call into Odoo, pair it with MuK REST API.
Help and support
What is covered after you buy, and where to write.
30 days of complimentary support for issues with the module, from the date of purchase. Data recovery, migration and training are not covered.
support@mukit.at for a technical issue — with your Odoo version and the request you sent. sale@mukit.at for anything before you buy.
MuK Proprietary Licence v1.0 — one database per licence. You may build modules on top of it; you may not redistribute it.
Want more?
MuK IT — Austrian Odoo partner, ViennaModules written for your process, on your Odoo version.
Odoo joined up with the systems you already run.
Hosting, deployment and upgrades you do not have to watch.
Your team taught the parts of Odoo they actually use.
An agreement, so an answer does not depend on who is free.
Documentation
The full text is on the Documentation tab, and in doc/ inside the download.Odoo.sh or on-premise, Community or Enterprise. OAuth2 needs the oauthlib and requests-oauthlib Python packages; without them, Basic, Digest and Bearer tokens still work.
Settings › Webhooks holds the webhooks, the authentications and the log. The server config file allows private targets, turns SSL verification off everywhere and sets the queue's batch size and the log's retention.
Depends on base_automation, base_import and muk_web_utils. Install it from the Apps menu like any other module.
Create a webhook as an action, an automation or a schedule, try it with Preview, then follow its requests from the Analytics button.
Webhooks, authentications and the request log are records, and an upgrade keeps them. Coming from 19, a webhook that processed its response gets Handle Error switched on, so its error code keeps running.
MuK IT GmbH, Vienna. Author and maintainer.
Have a system that should hear from Odoo?
Tell us what has to be sent and when, and we will tell you whether it is a webhook, an automation or a module. MuK IT — Austrian Odoo partner, Vienna.
| Availability |
Odoo Online
Odoo.sh
On Premise
|
| Odoo Apps Dependencies |
Discuss (mail)
|
| Community Apps Dependencies | Show |
| Lines of code | 2796 |
| Technical Name |
muk_webhooks |
| License | See License tab |
| Website | http://www.mukit.at |
MuK Webhooks
Turns Odoo server actions into HTTP webhooks. Each webhook has its own method, URL, headers, timeout and authentication (Basic, Digest, Bearer token or OAuth2), and Python code can adapt the URL, the headers and the payload and process the response or the error. Webhooks run from actions, automation rules and scheduled actions, are sent immediately, after the commit or from a queue with retries, and every request is logged with its credentials masked.
Installation
To install this module, you need to:
Download the module and add it to your Odoo addons folder. Afterward, log on to your Odoo server and go to the Apps menu. Trigger the debug mode and update the list by clicking on the "Update Apps List" link. Now install the module by clicking on the install button.
Upgrade
To upgrade this module, you need to:
Download the module and add it to your Odoo addons folder. Restart the server and log on to your Odoo server. Select the Apps menu and upgrade the module by clicking on the upgrade button.
Configuration
Everything lives under Settings -> Webhooks:
- Configuration -> Authentication holds the reusable sign-ins: Basic, Digest, Token (sent as a Bearer token) and OAuth2 with the password or the client credentials grant. OAuth2 needs the oauthlib and requests-oauthlib Python packages (requirements.txt); without them the option is not offered.
- Hooks -> Actions, Hooks -> Automation and Hooks -> Schedules create webhooks as server actions, automation rules or scheduled actions.
A webhook is configured in its form: URL, method (GET, POST, PUT, DELETE or a custom verb), timeout, Verify SSL, run type (one request per record or one for all), send type (immediately, post commit or cron job), maximum retries and error handling for the cron queue, header lines, the fields to include and the authentication. The toggles Adapt URL, Adapt Headers, Adapt Payload, Process Response and Handle Error each open a tab for Python code. The Help tab lists the variables every code block receives and what it may assign:
- Adapt URL: action_url holds the configured URL; assign request_url. authentication holds the configured credentials; assign another authentication record, or an empty one, to send the request with other credentials. The request log shows the credentials each request used.
- Adapt Headers: change headers or assign a new dictionary.
- Adapt Payload: assign content to extend the default payload or payload to replace it (a dictionary, a list or a string such as XML built with etree).
- Process Response and Handle Error: request, response and, for errors, exception; assign action to return an action to the user.
The server configuration file accepts these options:
- webhook_allow_private: allow URLs that resolve to private or internal addresses, which are refused by default.
- webhook_verify: set to False to skip SSL verification for every webhook.
- webhook_request_batch_size: requests sent per run of the queue (default 100), also the system parameter muk_webhooks.webhook_request_batch_size.
- webhook_request_autovacuum: days a sent or failed request is kept in the log (default 90), also the system parameter muk_webhooks.webhook_request_autovacuum.
Usage
A webhook fires where its server action does: from the Actions menu of a record, from an automation rule or on a schedule. The Preview button runs it on a chosen record and shows the headers, payload, request and response; Send Request calls the endpoint for real and Reset Changes rolls back what the code wrote.
Every request is logged under Analytics -> Requests with the rendered request and response, Authorization, cookie and API-key headers masked. Traffic and Hooks chart the log, and a failed request can be sent again from its entry.
The import dialog has a Run webhooks during import checkbox. It is off by default, so an import does not send webhooks, and a test import never sends.
Credits
Contributors
- Mathias Markl <mathias.markl@mukit.at>
Author & Maintainer
This module is maintained by the MuK IT GmbH.
MuK IT is an Austrian company specialized in customizing and extending Odoo. We develop custom solutions for your individual needs to help you focus on your strength and expertise to grow your business.
If you want to get in touch please contact us via mail (sale@mukit.at) or visit our website (https://mukit.at).
MuK Proprietary License v1.0 This software and associated files (the "Software") may only be used (executed, modified, executed after modifications) if you have purchased a valid license from MuK IT GmbH. The above permissions are granted for a single database per purchased license. Furthermore, with a valid license it is permitted to use the software on other databases as long as the usage is limited to a testing or development environment. You may develop modules based on the Software or that use the Software as a library (typically by depending on it, importing it and using its resources), but without copying any source code or material from the Software. You may distribute those modules under the license of your choice, provided that this license is compatible with the terms of the MuK Proprietary License (For example: LGPL, MIT, or proprietary licenses similar to this one). It is forbidden to publish, distribute, sublicense, or sell copies of the Software or modified copies of the Software. The above copyright notice and this permission notice must be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Please log in to comment on this module