Odoo homepage screen

Installing Odoo frontend and backend on different servers

In this tutorial I will teach you how to separate your Odoo frontend and backend. I will install the Odoo codebase/frontend on one server and the backend (your PostgreSQL server and database) on another server. You will learn how to configure both Odoo and PostgreSQL to achieve this.

1. Introduction

In order to achieve and demonstrate this setup to you I will be working with two virtual machines.
I will refer to the Odoo codebase/frontend server as the ‘frontend server’. The PostgreSQL server and database will be named ‘backend server’ throughout this tutorial.
My frontend server has the IP 192.168.118.167 and my backend server has the IP 192.168.118.168.
Tip: Make sure that both your servers have a fixed IP, otherwise your setup will break due to IP changes!

2. Configuring the backend server

Let us start with the configuration of the backend server. This server will contain the PostgreSQL server and the database(s).

2.1 Installing postgreSQL

Open up a terminal on your backend server and install PostgreSQL if you haven’t yet:

2.2 Creating the PostgreSQL user

Now create a new PostgreSQL user. Make sure that the PostgreSQL username matches with the username of the user running Odoo on your frontend server. In my example I will create a new PostgreSQL user with the name “odoo11”:

After you execute this command the system will ask you for a password for this user. Fill in a password and confirm this password again.
Tip: Don’t forget to remember this password, you’ll need it later on.

2.3 Configuring pg_hba.conf

After installing the PostgreSQL server and creating the user we now need to configure the remote connections. As our backend server will be used for the database connections our frontend server needs to be able to access it. Open up your frontend server and get the IP of the server. In my example my frontend server has the IP 192.168.118.167. Now open up your pg_hba.conf file on your backend server:

Scroll in this file and search for the following line of code:

Add a new line after the existing one which contains your frontend server its IP address. As you don’t want to use the exact IP address you should use the /24 subdomain. In my example this results to 192.168.118.0/24 instead of 192.168.118.167. Your configuration file should now look like this:

Finally, save your file and close it. Your PostgreSQL now knows that you want to allow connections from the backend server (IP 192.168.118.167).

2.4 Configuring postgresql.conf

Your PostgreSQL still needs to know the listen address of your frontend server too though. To achieve this we have to edit the postgresql.conf file:

Find the ‘listen_addresses’ line, which looks like this by default:

Now add in the IP of your frontend Odoo server (in my example 192.168.118.192):

Tip: Don’t forget to remove the # in this line because otherwise this line will be skipped!
Save this file and close it.
You’ve now applied all the changes that you need to do on the backend server. Next reload the PostgreSQL service in order to apply all the changes:

3. Configuring the frontend server

Your backend server is done now. Switch to the frontend server and open up your Odoo configuration file.
Tip: If you haven’t installed an Odoo yet you can follow my tutorial here
Typically your Odoo configuration file is under /etc/ and is named your-odoo.conf:

Add or change the following parameters in the configuration file:

Finally, restart your Odoo service to reload your Odoo configuration:

When you now browse to your Odoo instance (on your frontend server) you’ll see that your new Odoo is ready to use.
Odoo homepage screen
That is all! You’ve now setup your own Odoo instance where the frontend and backend are split between two servers.

4. Tips

While this is everything that you need in order to split up the backend and frontend of Odoo there are still some things to consider.
Because of security reasons you’ll most likely want to encrypt all the data and place everything on SSL. This also includes the calls from the frontend server to the backend server.
After you’ve created a new database you should check if the database is in fact created on the backend server instead of on the frontend server. You can do this executing the following commands (one by one) on your backend server:

After running these commands you can see an overview of your databases and to what user the database belongs. In my example you can see a new database named ‘ABC’ which is owned by my Odoo/PostgreSQL user ‘odoo11’:
Database overview result backend

5. Conclusion

Setting up an Odoo instance where the frontend and the backend are split is actually quite easy. Due to the built-in parameters from Odoo it is very easy to configure the frontend side. When you split the frontend and backend up and apply extra security – such as HTTPS connections and VLAN’s – you’ll have a safer and more controlable Odoo instance.
If you’d like to learn more about the deployment of servers and the default Odoo parameters you can have a look at the official documentation.

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


PayPal

Odoo Experts

Installing and configuring Odoo on DigitalOcean

In this tutorial I will teach you how to install Odoo on a new DigitalOcean VPS. You will learn how to create a new account, create a new server (droplet) and how to install any Odoo version on it.
In this tutorial I will show you step by step how to create the server and how to install the Odoo thanks to my installation scripts.

1. Creating a DigitalOcean account

If you do not have a DigitalOcean account yet you should create one. If you do you can continue to chapter 2. You can create a new DigitalOcean account through this link, which will give you $10 for free to start with. After clicking on this link you will see the following screen:
DigitalOcean website
Simply click on the link, fill in an e-mailadress and a password and click on “Sign Up”. After doing so you’ll get an e-mail in your inbox. Open up the link in your e-mail and your account will be activated.

2. Creating a new server (droplet)

Now that you have an account it is time to create a VPS. DigitalOcean calls a VPS (or a server) a droplet. When you’re on the home screen after logging in you’ll see a button “Create”. After you click on this button you will see a dropdown that has an option called “Droplets“, click on it:
Create droplet button
After clicking on the button a new page will show up asking which OS you want to use and what specifications (with their prices) you’d like:
Droplet configuration

For this tutorial I will create an Ubuntu 16.04.3 droplet (VPS) with 2GB RAM, 2 CPU’s and 40GB storage. This will cost $20 per month at the time of writing. Choosing what server you need is up to you and depends on your requirements. Do know that a server with less than 1GB of RAM will not work out. Finally you will see some additional options, the ability to add an SSH key and to name your droplet (VPS) as you’d like:
Droplet configuration
I’d advice you to check on “Monitoring” as it has no extra costs but it allows you to configure warnings. For more information about monitoring you should read this article from DigitalOcean.
Now give your droplet (VPS) a name and click on the “Create” button. A few seconds later you will see that the droplet (VPS) is being created:
Droplet creation page
That’s it! You’ve just created a new droplet and are ready to connect with it.

3. Connecting with the DigitalOcean droplet (VPS)

Because you’ve just created a new droplet (VPS) you’ve gotten an e-mail in your inbox. Open up your mailbox and you will find an e-mail with all the information you need to connect to the remote server:
Droplet connection details

You can now SSH to the server with these details in order to configure the server and install Odoo. You can connect by using the Linux command ‘ssh’, which looks like this:

SSH tells Linux that you want to open up a secure connection, root is the username of the user you’re connecting with and 138.68.95.197 is the IP of the server.
After entering this command you will get the question if you’re sure to continue connecting, just type yes. Now you’ll need to enter the password that is inside the e-mail you’ve recieved from DigitalOcean. Finally the server will ask you your current password and a new one, in order to change your automatically generated password to a safer one. Go ahead and change your password, after doing so you’re good to go:
SSH connection

4. Installing Odoo

That wasn’t too bad right? Now there is just one more thing to do: install Odoo on the server!
In order to install Odoo on the server you can use my installation script, which does a lot of the installation automatically. You can find an installation script for every Odoo version on Github. In this example I will install Odoo 10, but you’re free to install any other version.

4.1 Downloading the installation script

  • If you want to install Odoo 10 you can run the following command:
  • If you want to install Odoo 9 you can run the following command:
  • If you want to install Odoo 8 you can run the following command:

As a result you will get a new file (named ‘odoo_install.sh’) on your system which contains all the code to install Odoo:
Download installation script

4.2 Configuring the installation script

Now open up the file and edit the parameters to your liking:

There are some things you can configure/change to your likings at the top of the script. You can choose if you wish to install Wkhtmltopdf or not, which version you’d like, where the location is and most importantly what the master admin password is.
Tip: always modify this for every Odoo you install!
If you want the enterprise version of V10 you should change the line IS_ENTERPRISE to true:

If you want the community version you can just continue and keep the IS_ENTERPRISE key on False (which is the case by default):

4.3 Making the Odoo installation file executable

The next step is to make this file executable. After you’ve made it executable you can execute it and everything will be installed automatically.
You can do this with the following command:

4.4 Running the installation script

Now that the code is in your file and the file is executable you simply have to execute it with the following command:

You will see that the script automatically starts updates, downloads required packages, creates the user, downloads the code from Github, … Eventually, if you’ve chosen to install the enterprise version, you will need to give in your Github credentials to download the Enterprise code (since this is a private repository). Fill in your details and let the script continue:
Enterprise authentication
Finally, give the script a few minutes to configure and install everything and eventually you will see something like this:
Result installation script

You now have a fully functional Odoo on your system! Congratulations.

4.5 Accessing your Odoo

Good job! You’ve created a DigitalOcean account, created a droplet (VPS), configured it and installed Odoo on it. Now it is time to enjoy the results of your hard work. If you now open up your browser and surf to your IP and the port you’ve installed Odoo on (by default 8069) you can see your Odoo is up and running. Because the droplet (VPS) is automatically connected to the internet (a public IP address) your Odoo will also be publicly available. Go to http://yourip:yourport and you will see your just installed Odoo:
Public Odoo page

4.6 Security advisory

As security is a very big topic I did not add anything about security in this tutorial. Please do configure your Odoo with a firewall, Nginx, SSL and best security practices. The security part is out of scope in this tutorial because of the size of the subject but please do add in security rules.
For more information please do look at Nginx, the official DigitalOcean security measures and LetsEncrypt.

5. Conclusion

Creating a new server, configuring it and installing an Odoo on it is very easy with DigitalOcean. You’ll have a VPS in a matter of minutes for an affordable price. Due to the accessibility and flexibility of DigitalOcean and Odoo it has never been so easy to have an ERP publicly available.

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




PayPal

Odoo Experts

Installing Odoo 9 on Ubuntu 16.04

Hi guys,

1. Introduction

In this tutorial I will teach you how to install Odoo 9 on Ubuntu 16.04. The script that you will use is based on the code from André Schenkels but has been updated and improved.

2. Downloading the script

The first step is to download my script from Github and to add the code in a new .sh file on your Ubuntu machine, wherever you’d like this.
For example right under /home. Open up an Ubuntu terminal and cd to the directory where you’d like to keep the script and then create the file:

If you’re curious about how the whole code looks and works you can find it on my Github account.

Now open up the file and edit the parameters to your liking:

There are some things you can configure/change to your likings at the top of the script. You can choose if you wish to install Wkhtmltopdf or not, which version you’d like, where the location is and most importantly what the master admin password is.
Tip: always modify this for every Odoo you install!

3. Making the Odoo installation file executable

The next step is to make this file executable. After you’ve made it executable you can execute it and everything will be installed automatically.
do this with the following command:

4.Running the script

Now that the code is in your file and the file is executable you simply have to execute it with the following command:

You will see that the script automatically starts updates, downloads required packages, creates the user, downloads the code from Github, …
Give the script a few minutes to configure and install everything and eventually you will see something like this:
Result install script

You now have a fully functional Odoo V9 on your Ubuntu 16.04! Congratulations.
Odoo V9

5. Extra information

In the script you saw there was an option to change the Odoo port (OE_PORT). When you’d change this port number to 8070 in the install script it would be applied to /etc/your-config-file.conf and this would give you the ability to change the default port.
To apply these changes you should do the following:
Changing Odoo settings
The -c will change the configuration and memorize what you’ve changed under /etc/your-config-file.conf. Because my port was set to 8070 this is telling the Odoo that it should run on port 8070. When you would now open up your browser and navigate to http://localhost:8070/ you will see it is running there:
Odoo V9 alternative port

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


Odoo Experts

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

Installing Odoo 9 enterprise on Ubuntu 14.04

Hi guys,

1. Introduction

In this tutorial I will learn you how to install Odoo 9 Enterprise on Ubuntu 14.04. The script that you will use is based on the code from André Schenkels but has been updated, improved and I’ve added Enterprise support. Do notice that you will need to be an official partner or that you need to have bought the Enterprise subscription from Odoo or you will have no access to the Github repository for the Enterprise code!

2. Downloading the script

The first step is to download my script from Github and to add the code in a new .sh file on your Ubuntu machine, wherever you’d like this.
For example right under /home. Open up an Ubuntu terminal and cd to the directory where you’d like to keep the script and then create the file:

If you’re curious about how the whole code looks and works you can find it on my Github account.

Now open up the file and edit the parameters to your liking:

There are some things you can configure/change to your likings at the top of the script. You can choose if you wish to install Wkhtmltopdf or not, which version you’d like, where the location is and most importantly what the master admin password is. Tip: always modify this for every Odoo you install!

3. Making the Odoo installation file executable

The next step is to make this file executable. After you’ve made it executable you can execute it and everything will be installed automatically.
do this with the following command:

4.Running the script

Now that the code is in your file and the file is executable you simply have to execute it with the following command:

You will see that the script automatically starts updates, downloads required packages, creates the user, downloads the code from Github, … Eventually you will need to give in your Github credentials to download the Enterprise code (since this is a private repository). Fill in your details and let the script continue:
Odoo 9 Enterprise authentication
Give the script a few minutes to configure and install everything and eventually you will see something like this:
Result install script

You now have a fully functional Odoo V9 Enterprise on your system! Congratulations.
Odoo V9 Enterprise

5. Extra information about Odoo 9 Enterprise

Since Odoo Enterprise uses code from both http://github.com/odoo/odoo and github.com/odoo/enterprise we will separate the code with this script. This will make future upgrades easier and the code is nicely separated. This means that the default V9 code will be under /odoo/odoo-server/ and all the enterprise code will be under /odoo/enterprise/.

In the script you saw there was an option to change the Odoo port (OE_PORT). When you’d change this port number to 8070 in the install script it would be applied to /etc/your-config-file.conf and this would give you the ability to change the default port.
To apply these changes you should do the following:
Changing Odoo settings
The -c will change the configuration and memorize what you’ve changed under /etc/your-config-file.conf. Because my port was set to 8070 this is telling the Odoo that it should run on port 8070. When you would now open up your browser and navigate to http://localhost:8070/ you will see it is running there:
Odoo V9 alternative port

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




PayPal

Odoo Experts

Adding static resources (CSS and JavaScript) to Odoo

Hi guys,

In this tutorial I will learn you how to add CSS and JavaScript to your custom Odoo module. This gives you the ability to change the design of things in Odoo, to execute JavaScript (and jQuery) and opens up a whole new set of possibilities to add extra options in Odoo.

In this example I will learn you how to add new JS/CSS files to Odoo and how they should be added to Odoo by the official guidelines. At the end you can also find a link to a demo module so you can always look at a code example too!

1. Creating the XML

The first step is to create a new XML file in your custom module. Create a new XML file under yourModuleName/views, like this:
New XML file
Now the first thing to do is to tell __openerp__.py that you’ve added this new XML file, otherwise Odoo will not load it. Open up __openerp__.py and add in a line in the data block. Be sure to give it the correct path and filename:
Add the XML to __openerp__.py

Now return to your XML file. All CSS and JavaScript in Odoo is added to the assets so the first step is to create an inherit_id calling this, then we’ll use an xpath to add in our custom coded files. Adding resources is much like adding a field to a view with inheritance, you’re just referring to a file and not a field. So how does this look in code?

Let us break this down! We’ve created a new template called ‘assets_backend’, which has a name ‘static_resource_demo assets’ and which inherits ‘web.assets_backend’. The ‘web.assets_backend’ is already created by Odoo and contains all the CSS/JavaScript code so we’ll simply inherit it to add our files to it. The xpath expression is simply telling Odoo let us add those files to the main path of ‘web.assets_backend’. Simple, isn’t it?

2. Creating your CSS / JavaScript files

Alright so now that we have the basis done for adding in CSS or JavaScript files we should first create them. The guidelines of Odoo say that you should create a new folder named ‘static’, so do so. Open up this folder and create a new folder ‘src’. After you’ve created the folder ‘src’ you should create a new one named ‘css’, ‘js’ or ‘images’ depending on which file you need to add. In this example I will explain both. If you want to add CSS files read part 2.1, if you want to add JavaScript files read part 2.2 and if you want to do both, well read both.

2.1 Creating your CSS files

Create a new folder ‘css’ for this example and open it up. This is now the official structure for adding CSS files to Odoo! Now create a new CSS file in this folder. I’ve named it ‘cssfile.css’ just for demo purposes, but you can name this whatever you like. The final result will now look like this:
Folder structure for custom CSS file
So in my example I’ve created a custom module named ‘static_resources_demo’ in which I created the folders. From here on you can add all the CSS in your CSS file as you like!

This leaves us with one more thing to do. Odoo doesn’t know the path to the CSS file yet so open up your XML file again (in my case named resources.xml) and add the path to your CSS file:

An important note is that you should also add the name of your module in! The xpath and template know the path up in to the folder addons but from there on Odoo is lost if you don’t tell it where to look. So first add your module name and then continue with /static/src/css/yourFileName.css.

2.2 Creating your JavaScript files

Create a new folder ‘js’ for this example and open it up. This is now the official structure for adding JavaScript files to Odoo! Now create a new JS file in this folder. I’ve named it ‘javascriptfile.js’ just for demo purposes, but you can name this whatever you like. The final result will now look like this:
Folder structure for custom JS file
So in my example I’ve created a custom module named ‘static_resources_demo’ in which I created the folders. From here on you can add all the JS in your JS file as you like!

This leaves us with one more thing to do. Odoo doesn’t know the path to the JS file yet so open up your XML file again (in my case named resources.xml) and add the path to your JS file:

3. Conclusion

Adding CSS or JavaScript to your custom module is very easy and has a lot of possibilities. This is ideal if you want to change the layout of your Odoo, if you want to create another theme or if you want to have extra control with JavaScript. Adding extra resources gives you almost unlimited possibilties such as creating new widgets or adding external JS libraries in!

Do you want to try a demo module and see the source code of this tutorial? You can view on my Github account.
Has this tutorial helped you, do you have any feedback or questions? Post away!




Odoo Experts