Chapter 16: Polish Your Code And Submit Your PR
In the previous chapters we saw how to create a fully functional business application. Now we will prepare our code to be shared and learn how to share it.
We will start refactoring the code to match to the Odoo coding guidelines. The guidelines aim to improve the quality of the Odoo Apps code.
Reference: you will find the Odoo coding guidelines in Coding Guidelines.
Your first Pull Request (PR)
The following is intended to be used by Odoo staff members only. All repositories mentioned are not accessible for third-parties.
Now that your code respects the Odoo code guidelines and is polished up, let’s share it with others.
Configure development repository
We will start by creating a git development environment for the ‘custom’ folder, like we did in the beginning for ‘odoo’ and ‘enterprise’. The PR will target the
After you successfully created your development repository, we will configure your existing
$HOME/src/custom folder to be able to commit your work.
Note that if your work is already in a Git and GitHub configured folder the previous steps are not needed. This is the case when you start working in the ‘odoo’ or ‘enterprise’ folders.
Branch, Commit & Push
Before creating the PR, a new working branch has to be created and used to commit the code. Afterwards the branch will be pushed to the development repository.
Create your working branch:
Your branch name must follow the following name structure : <targetVersion>-<feature>-<trigram>
Example: The branch master-sale-fixes-abc on odoo-dev/odoo is a branch containing fixes for the sales app in the odoo/odoo repository, to be deployed in master and done by ABC.
Commit your code:
Everyone reads your commit messages!
The commit message is very important, follow the Git guidelines.
Push your new branch to your development repository:
Create your first PR
After pushing your branch to your development repository you will see an output similar to:
There are two ways to create the PR:
Click on the link displayed in the output of the push command.
Open a browser in your development repository
https://github.com/xyz-odoo/technical-training-sandbox. There will be a button to create a new pull request.
You will notice that your commit message is used as the pull request message. This occurs if you have only 1 commit. If you have multiple commits, you can either make a summary of the commits as the PR message or if there aren’t that many commits you can just copy/paste your commit messages as the PR message.
Test on the runbot
Odoo has its own CI server named runbot. All commits, branches and PR will be tested to avoid regressions or breaking of the stable versions. All the runs that pass the tests are deployed on their own server with demo data.