Introduction
Managing software development projects in Odoo can become much more efficient by leveraging Odoo automation. This efficiency is further enhanced with the power of OCA (Odoo Community Association) modules.
In this guide, we will walk you through automatically updating tasks in Odoo 16.0 based on GitHub events, streamlining your workflow and reducing manual interventions.
Scenario
Imagine this scenario:
- A developer opens a pull request (PR) in GitHub and inserts a link to the corresponding task in Odoo.
- Whenever the PR status changes, the task in Odoo is automatically updated.
- The kanban status (colored button) in Odoo is updated based on labels added/removed in GitHub.
- Task activities are marked as done automatically, improving workflow efficiency.
This automation ensures better synchronization between GitHub and Odoo, eliminating the need for manual updates.
Module installation
To implement this automation, install the following OCA modules:
- Endpoint - Enables external API interactions in Odoo
🔗 GitHub Repository - RPC Helper - Supports remote procedure calls in Odoo
🔗 GitHub Repository- (Note: If installing via pip, this module will be installed automatically.)
- Project Task Pull Request - Links GitHub PRs to Odoo tasks
🔗 GitHub Repository - Project Task Pull Request State - Syncs PR status between GitHub and Odoo
🔗 GitHub Repository
Quick Installation Tip:
To install all modules in one step:
- Type “endpoint” and “pull_request” in the Odoo Apps search bar
- Switch to List View
- Select the required modules using checkboxes
- Click Actions > Activate Modules
Dependencies will be installed automatically!
Odoo Modules Configuration
Project Task Pull Request
- Open the project which you would like to configure.
- Select stages in which pull request will be required and also set default pull request state for this project.
- Hint: you can configure the default pull request globally in the General Settings.
Endpoint
Activate the developer mode and go to the “Settings > Technical > Endpoints” menu.
Create a new endpoint with the following settings:
- Name: Github or any one you like
- Route: /github or any one you like
- Exec mode: Execute code
- Exec As User: choose a user that will be used to execute the code. This user must have write access to projects and tasks the webhook will be used in.
- Auth Type: Public. Don’t panic! We will use the token and will check it in the code.
- Request Method: Post
- Request content type: JSON
Now let’s switch to the “Code” tab, paste the code below into the “Code” field and do the following steps:
- Line #1. Replace the secret in with your own one. This secret will be later used in GitHub.
- Line # 8. Configure events you would like to process in Odoo. This code handles pull requests only, but you can modify it to use any events you like.
- Line # 14. Task stages. This is a Python dictionary that uses task stage name as a key and task stage id as a value.
To get the task stage id activate the developer mode, go to “Project > Configuration > Task Stages”, open the task stage you want to add and get id from the “id” key in the browser url.
Eg in the “https://myodoo.example.com/web?debug=1#id=3?&cids=1&menu_id=113&action=187&model=project.task.type&view_type=form” id is “3”. - Line #73 from here starts the part of the code that changes kanban state based on PR labels. Although label names are hardcoded here, you can easily put your own ones using the code as an example.
After that click the “Action” menu and select the “Sync registry” action. I recommend restarting the Odoo server too in order to ensure that endpoint is working properly.
GitHub settings
For testing we will configure a webhook for a single repository. However it can be configured at the organization level too.
In the repository, switch to the “Settings” tab, select “Webhooks” from the left menu and click “Add webhook” button.
Fill the following values in the fields below:
- Payload URL: your Odoo instance URL + endpoint. Eg “https://myodoo.example.com/github”
- Content type: application/json
- Secret: the one you have configured in your endpoint in line #1
- Enable SSL verification: if your domain is using “https://” prefix then yes. Otherwise why are you not using it?
- Which events to trigger. That depends on your code. You can set “All events”, however it’s recommended to specify exact events, eg “Pull request” to avoid excessive calls.
When all is set click “Add webhook” and GitHub will send a “ping” event to Odoo. If everything is set correctly then this request will be marked with a green check.
Let's try it!
So now as we all set it’s time to see how it works.
Create a new PR in your repository and copy its link into the “PR URI” field in the task.
Now let’s update the PR state to “Draft”.
PR status in Odoo will be automatically changed to “Draft”:
Fine, not let’s merge our PR. First of all we need to click “Ready for review” than “Merge pull request” and confirm the merge.
PR status in Odoo will be changed to “Merged”:
Bonus: Odoo Automated Action
Want to take automation further?
Here is an example of an automated action that updated task stage and kanban status based on PR status and also marks activities as “Done”. You can use this code as a basis and add your own values or modify the flow and implement some custom actions.
Conclusion
By integrating GitHub events with Odoo, you can: ✔ Reduce manual effort in updating tasks ✔ Enhance project tracking with real-time PR status updates ✔ Automate repetitive actions, making your workflow more efficient
With the help of OCA modules, Odoo becomes an even more powerful project management tool. 🚀
Video Version
You can also check the video version of this tutorial on YouTube:
Automate Odoo Task Workflows with GitHub Events