Updating your Odoo from Github

Hi guys,

In this tutorial I will teach you how to update your Odoo code from Github. In this tutorial you will learn how to use terminal commands to update your local Odoo installation.

In this example I will learn you how to update your Odoo environment from Github and how you can update your database in order to use the newest code.

1. Navigating in to the correct folder

The first thing that you will need to do is to navigate in to the correct folder from your terminal. Usually your Odoo is installed right under the root folder and has a structure along the lines of /odoo/odoo-server. In my local example I’ve installed an Odoo 9 under /odoo9/odoo9-server:
Odoo folder location
So, how do you know in which folder you need to be? if you see the same structure as in my above screenshot you’re in the right place. You should see the odoo.py and addons folder.

2. Fetch content from Github

Now that you’re in the correct folder you should fetch the content from Github in order to apply it locally later on. Fetch the content from Github:

So, what does this line do? Sudo will execute this command with administrator priveleges, git fetch will tell the system that we want to fetch content from github, origin refers to the origin where Odoo comes from (http://github.com/odoo/odoo) and 9.0 is the Odoo version.
Tip: If you have Odoo version 8 you should replace 9.0 with 8.0.
After running this command you will see the following result:
Github fetch origin

3. Apply all changes

You now have everything fetched and you should now tell the system to apply this. At this point the system knows which files and changes need to be made, but you didn’t make them yet. You can do this with git reset. The code:

Tip: git reset –hard will apply all changes, no matter what. If you did add custom code in already existing modules (so in the source code and not in a self made module) you should not use this. Your custom code will be overwritten with this! This is however against all the rules, so if you do code in the source code please start with creating your own modules in place of adding in the source code.
Tip #2: Do you have another version? Simply change 9.0 with the Odoo version you have running. For example if you have Odoo 8:

After you’ve used this command you will see a result similar to this:
Github reset hard example
So, what does this refer to? If I open up Github and look at the latest change that has been made to Odoo you will see that these match up:
Github reset result on Github
As you can see your Odoo code is now up-to-date and is at the latest change that has been made by Odoo.

4. Updating the database

Congratulations, you’ve already updated your whole Odoo code! That was simple, right? There is just one more thing to do. You should now update your database so that the database knows about all changes and applies them in the database.
There are multiple ways to do this but the most simple one is to restart the Odoo service with the correct parameters to update the odoo. Every Odoo has a service running and usually has a name along the lines of odoo-server. Type the following command in your terminal:

Let us break down the whole command to know which part does what.
sudo service odoo9-server restart tells the system to restart a service (so, an Odoo environment). -u all will tell the Odoo to update all modules and -d YourDatabaseName will tell the Odoo to do these changes on the database named ‘YourDatabaseName’.
Tip: Want to know more about the possibilities of the command-line interface? Have a look at the official documentation!

That is all, you’re done! After you’ve run this command you’ve updated the whole database with the latest code.

5. Conclusion

Updating an Odoo environment from Github is actually really easy. Your users will not notice anything (besides of a minor delay when reloading the database) and your system will not need to go down when updating an environment.

Has this tutorial helped you, do you have any feedback or questions? Post away!




PayPal

Odoo Experts

28 thoughts on “Updating your Odoo from Github

    • Yenthe666 says:

      Hi Ray,

      Do exactly what is explained in this tutorial. After this you move in to the directory enterprise/addons and then also do a git fetch origin and git reset –hard in the enterprise/addons folder. Do another -u all (and -c /etc/odoo-server.conf) and you’ve also updated the Enterprise code.

  1. Daniel says:

    Hi Yenthe,

    Thank you very much for the great job you doing. The tutorial has helped some of us a newbies to odoo.

    Could you please write a script that could deactivate some users on a set date defined?

    For instance, allow some users to have access the apps for just a month.
    Thanks in advance

    • Yenthe666 says:

      Hi Daniel,

      You’re welcome! Sadly at this point I don’t have enough time to help with people with requests / create other modules. The thing that you want to do is not to hard though. Create an automated scheduler that runs once a day, create a model with a link to an user and set an enddate on this. You can then de-activate records from the automated action.

  2. David Gouthière says:

    Hi Yenthe,

    Thanks a lot to share such information with persons like me who are just not technicians and would be really blocked without this ad-hoc support. A small thing here, but necessary.
    I have to fight with Odoo/Linux jargon and vocabulary when I just want to use a great business tool.
    You input is really useful.

    With kind regards,
    David

    • Yenthe666 says:

      Hi David,

      Thanks a lot for the great feedback, it is great to read such positive feedback!
      Best of luck with Odoo!

    • Yenthe666 says:

      Hi krishuang,

      Upgrading from one Odoo version to another is not that simple. You will need to let Odoo do your upgrade if you have an enterprise version or use the open source alternative OpenUpgrade.

  3. I cloned my repo with git clone git@github.com:odoo/odoo.git --branch 10.0 --depth 1 --single-branch so I needed to fetch with --depth 1 too.

    In the other hand, services doesn’t receive parameters, so the -u all needs to be supported inside the daemon file.

    Thanks Yenthe!

    • Yenthe666 says:

      Hi Mateo,

      Thanks for the extra info. You could trigger the updates from the front-end too though with “Update modules list”. Perhaps it would be neat to support on daemon level.

    • Yenthe666 says:

      Hi Ahsan,

      Yes your custom development will stay intact. It will only update all the modules that are on Github. Also, always backup your custom development somwhere else though. 🙂

  4. Hi Yenthe,
    If I have installed the Odoo Enterprise with the package installer, would it be still possible to update it correctly with your script?

  5. Are you referring this tutorial with the community version or enterprise. I’m on community version. I’m confused with the latest structure of Odoo in github:

    If you look at the github repository at odoo/odoo (Branch 10.0), it contains addons folder and inside this folder we only have test files. But from the production installation, the structure is different.

    How to actually update my odoo when this folder structure of Odoo in centOS 7 with the github both are different.

    My default installation package in CentOS is here:

    cd /usr/lib/python2.7/site-packages/odoo/

    inside this folder I have an addons folder.

    Really need help on this

    • Yenthe666 says:

      Hi Arafat,

      This tutorial shows you the community version. The git fetch is pretty much identical for enterprise though, you just have to be in the enterprise folder. You can simply navigate into your addons folder and update it from there.

  6. Luis Guzman says:

    I wonder…
    Is there a way to confirm inside the WebUI that the changes were applied?

    I mean, if for some reason the Module Update was not executed,is there a way to confirm it?

    The Settings page/dashboard only shows the branch version.

    Thanks 😀

    • Luis Guzman says:

      On a closer look, from the WebUI you need to “Upgrade” every single module, to get the latest code.

      Even when it may seems tedious I believe it’s a good approach since, some modules won’t run after the changes, and if you upgrade all at once you wouldn’t be able to know (without a lot of debugging) which is the one causing issues and end up with a 500 error.

      https://ark.switnet.org/files/module-update.png

Leave a Reply

Your email address will not be published. Required fields are marked *