Using and updating Submodules with Git and Odoo.sh

Aus dem Nähkästchen geplaudert: Hier gibt es aktuelle News und Insights der ERP-Implementierung. Zusätzlich findet man hilfreiche Tipps zu den Themen Projektmanagement, Prozessoptimierung und Digitalisierung.

Introduction

This article discusses Git-Submodules and their use with Odoo.sh in combination with the Git-GUI "Tortoise Git".

​For the purpose of this article it's important to distinguish between 3 definitions:

  • Original Submodule-Repository: The repository that is used to store code of a specific submodule. The functionality of the module is coded and pushed to that repository

  • Odoo.sh-linked Repository: The repository that is linked with the Odoo.sh-Account It will contain the "Original Submodule-Repository" as a submodule

  • Submodule-Folder in Odoo.sh-linked Repository: Folder that contains code from "Original Submodule-Repository" and is stored within the "Odoo.sh-linked Repository"

What are Submodules

This is section gives a short introduction to Submodules - for detailled descriptions please refer to the Git documentation: Git-Tools - Submodule

Git-Submodules offer a way to use code from another project or repository within your own codebase while still being able to pull code for that other repository regularly. 

Odoo.sh makes use of this Git functionality - submodules can be used to easily add new functionality from standard-repositories which can be reused for multiple Odoo.sh-projects while still refering to the same codebase.

Private and Public Submodules

​One has to distinguish between private und public submodules. Private Submodules need an extra step in order to make sure that Odoo.sh is able to pull code from that repository.

Adding Submodules to your Odoo.sh-project

To add Submodules to Odoo.sh please follow the following steps:

  • • Only if the Submodule is private:
    • o Go to the settings tab of your Odoo.sh-project and add the link to your private Submodule under the "Submodules"-section.
    • o Copy the generated Public Key and add it as "Deploy-Key" on Github (Settings => Deploy Keys)
  • • For all Submodules:
    • o Head to the "Branches"-Tab of Odoo.sh select "Submodule" in the top-right-corner and click "Run on Odoo.sh Enter the path to your repository again, select the right branch and click on "Add Submodule".
    • Odoo will issue a new build and after that you will be able to Update the App-list within the Odoo App-Installation page and install your new modules from your submodule.

Updating Submodules with Tortoise Git

Updating Submodules gave us some headaches, that's why we decided to document how we made it work.


First: Make changes to the Original Submodule-Repository

To make changes to your submodule, simply clone the original submodule-repository using Tortoise Git, apply your changes, commit and push.

Update the Submodule-Folder in the odoo.sh-linked Repository

​In order to load your changed code into the odoo.sh-linked Repository and use it in Odoo.sh you have to pull the new Code into the Odoo.sh-linked Repository.

This is where we struggled as we got some error-messages from Tortoise-Git. One of the most-common error-messages we got was:

Permission denied (publickey).
fatal: Could not read from remote repository.
or
fatal: Couldn't find remote ref

Here are the steps to make sure that you can pull code from your Submodule-Repo:

  • Make sure that your personal Github Account has at least read-permissions for the submodule-repository that you are trying to pull. You can do this by opening the repository on Github => Settings => Manage access and add your account as a team-member.

  • Create an SSH-key for your personal account: Open your personal profile settings (https://github.com/settings/profile) and head to "SSH and GPG keys".

  • Click on "New SSH key" and enter any title for the newly created SSH-Key

  • Next you would need to enter a key. To do so, open "Puttygen" (it should be located in the bin-folder of your TortoiseGit-Installation folder (C:\Program Files\TortoiseGit\bin)) and hit the "Generate"-Button.

  • Copy the generated key and paste it in your git-page within the "Key"-text box

  • Go back to Puttygen and Save both the Public and Private key to a folder of your choice.

  • Next, open Pageant (which should be located at C:\Program Files\TortoiseGit\bin if you are on a Windows-machine), click "Add key" and select your private-key-file that we created earlier.

  • Next, right click on your odoo.sh-linked repository folder and select Tortoise-Git => Settings. In the following window head to Git => Remote , select the "origin"-Remote and add the Path to your private Key in the "Putty Key"-Form-field.

  • Additional Check: Make sure your Tortoise-Git-Client is using the right SSH-client. To do so open Tortoise-Git-Settings and go to the Network-Settings. Make sure that TortoiseGitPlink.exe is set as SSH-Client (C:\Program Files\TortoiseGit\bin\TortoiseGitPlink.exe).

  • Now head to the odoo.sh-linked repository and open the Submodule-Folder that you want to update. Right click anywhere and Select "Tortoise Git" => Pull. In the pop-up, make sure that you select the correct Remote Branch (this Branch-Name must be existent in the Original Submodule Repository (!!)).

  • If everything worked well, Tortoise Git will pull the updated code without any error-message.

  • Next, head back to the main-folder of the odoo.sh-linked Repository, Commit and Push.

  • ​All done!

Odoo v14 and Outlook Calendar
Use the possibilities of Odoo and connect Odoo with Office 365