1. Introduction to submodules
Tip: If you haven’t made an Odoo.sh project yet you can follow my tutorial here .
So, what exactly is a submodule? A submodule is a link from one Github repository to another repository. You can see it as a virtual pointer to a specific commit in time of the remote repository.
For Odoo.sh there are two major differences. You have public submodules and private submodules. Public repositories are those that are publicly available
(for example https://github.com/odoo/odoo ). Private repositories are the repositories that are not publicly available. Usually you have private repositories when you work for a company and when you manage customer code.
There is a big difference in using public or private submodules on Odoo.sh though. When you have a public repository you can easily add the submodule and it will work. For a private repository you will need to generate a deploy key on Odoo.sh and then add it on the remote Github repository.
1.1 Why use submodules?
Now we know what a submodule is but the question is why would you use a submodule? Submodules are very handy to use if you want to include third party apps in your Odoo.sh tests. The only other way to get this code available in your Odoo.sh builds is to add all this third party code in your own repository. But what if the third party developer has made a lot of changes, fixes or improvements? If you don’t use submodules you will constantly need to download the remote apps, add them to your own repository and keep track of all those changes. This is the true power of submodules. Now let us first link a public repository to the Odoo.sh project in chapter 2.
In chapter 3 I will learn you how to add a private repository as a submodule.
2. Public repositories
Setting up public repositories is really very easy to do.
You will need to create a submodule and commit it to Github. Go to your Github repository, switch to the correct branch and add the submodule from the command line:
- git clone ssh/http github repo (git clone firstname.lastname@example.org:oca/odoo15.git)
- git checkout branch_name ( switch to the correct branch)
- git submodule add -b 15.0 email@example.com:oca/hr.git
- git add -A && git commit -m "[ADD] submodule: add OCA/hr as submodule"
- git push
* This new commit will trigger a new Odoo.sh build. After this build is ready you will see that the modules from the OCA/hr repository are available on your instance
Great job! This is all you need for a public repository. If you also have a private repository and want to add it then continue to the next chapter.