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:
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:
|
sudo git fetch origin 9.0 |
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:
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:
|
sudo git reset --hard origin/9.0 |
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:
|
sudo git reset --hard origin/8.0 |
After you’ve used this command you will see a result similar to this:
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:
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:
|
sudo service odoo9-server restart -u all -d YourDatabaseName |
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’.