Configure Odoo10 And Odoo11 For Development In Windows10

In this tutorial i will explain how to set up both Odoo10 and Odoo11 in Windows10 for development purpose. We will be configuring the Odoo10 in normal system environment where as Odoo11 will be in virtual environment, so that we can avoid any future glitches of having both python versions. You can configure both Odoo in conversely also ,or both in virtual environment.

Like all tutorials i have divided whole configuration to 4 tiers so that everyone can easily understand.

Setting Up Common Dependant Applications

There are few application that we needed for both version. In this phase we will be setting up PostgreSQL, Node.Js, wkhtmltopdf and Git.

Configuring Git In Windows

For installing git you can download the windows executable from here. Git can be used for downloading the Odoo code repository. So that we can be upto date with any changes. This will install the git bash which is similar as the linux shell. so you can use some linux commands also.

Configuring PostgreSQL

Odoo uses PostgreSQL as it's primary database, you can download it from their official site. When installing be sure to remember the PostgreSQL root user password, superuser by default will be postgres. To access the psql interpreter, first you need to add the PostgreSQL bin directory to the windows system environment. Don't overwrite any variables that already in there. The default bin directory is C:\Program Files\PostgreSQL\9.6\bin.

Then you can use any commands provided by psql interpreter in windows command prompt or in git bash. For more information on the psql commands you can check this cheat sheet.If you can not execute psql commands, it may be because of this error.For odoo to create database, we need to create new role for the Odoo. It can be done as follows.

                            
                            
// PostgreSQL commands
psql -U postgres // entering the psql interpreter as postgres user
CREATE ROLE odoo WITH LOGIN NONSUPERUSER INHERIT CREATEDB NOCREATEROLE PASSWORD 'odoo'; // role odoo with password odoo
\du // check whether role is created

Configuring Node.Js

Node.Js is for installing the css preprocessor that is used to handle the Odoo css files. Node for windows can be download from here. Node packages can be installed using the npm, which is the default packet manager for Node and comes in default. After installing it, you can type node --version in command prompt to verify it.

                            
                            
// node npm commands
npm install -g less // installing less
npm install -g less-plugin-clean-css // less css

Configuring wkhtmltopdf

In order to print pdf reports in Odoo we have to install the wkhtmltopdf. It can be found here. Remember to download the 0.12.1 version because Odoo10 and Odoo11 is more compatible with that. After that add the bin folder to the system environment variables, so that it can be used by Odoo. Type wkhtmltopdf --version in command prompt to verify the installation.

Configuring Odoo10

After setting up the common applications, next we need to download the python2.x from here. Remember to download the 32 bit version, because python package support is more in 32 bit version. After installing the python, add the installed folder to system environment variables. The two paths you needed to add are C:\Python27 and C:\Python27\Scripts, latter one is for enabling the use of pip in command prompt.

Then clone the Odoo to the desired path using the following command. and install the python dependencies using the pip, dependency list can be found in the requirements.txt file inside the Odoo folder.

                            
                            
// Cloning Odoo
git clone https://www.github.com/odoo/odoo --depth 1 --branch 10.0 --single-branch // Cloning Odoo
pip install -r requirements.txt // install the python dependencies

If any error occurs, you have to install the packages one by one. After installation go the cloned odoo directory which has the odoo-bin file. Use the command prompt or git bash to run the Odoo using the following CLI command.

                            
                            
// Running Odoo10
python odoo-bin -r odoo -w odoo // running Odoo with default config

In the command we have to specify the postgres role and password. So use the role (-r odoo) and password (-w odoo) you provided.If you get any error on win32service. You can get the 32 bit version from here. If everyhting ok you can see the working Odoo in the default ip address localhost:8069. You can change the parameters of the CLI, for that please check my tutorial on that. Also don't forget to allow exception for python in the windows firewall.

Configuring Odoo11

We will be installing Odoo11 in an virtual environment because Odoo11 uses python3.x, we have to download the python3.x latest from their official site. Install it in the folder C:\Python36. Then change the python script inside that to python36, so that we can distinguish between both version. Finally add directory to the system environment variable list.

Now next step is to create a virtual environment using the python3.x.It can be done by the following command on command prompt.

                            
                            
// Setting up venv
python36 -m venv path_to_folder // create venv in specified path
source folder_name/Scripts/activate // activating the venv
deactivate // deactivating the venv

Next we have to clone the Odoo11 from the git repository using the following commands.

                            
                            
// cloning Odoo11
git clone https://www.github.com/odoo/odoo --depth 1 --branch 11.0 --single-branch // cloning the odoo11
pip3 install -r requirements.txt // installing the python dependencies

Activate the venv using the above command, you can verify python version and which python is we using by pip --version command. After that go to the Odoo11 cloned folder and install the python dependencies using the above command. For this follow the same steps that i described for Odoo10 here also. If you get the win32service import error install it using the command pip3 install pywin32. Last but not least run the Odoo11 as follows. And can see the Odoo11 running on localhost:8069. Finally deactivate the venv once it is done.

                            
                            
// Running Odoo11
python36 odoo-bin -r odoo -w odoo // running Odoo with default config

Extra References

Consider this tutorial as a basic guide for setting up an Odoo development environment in Windows10. You can switch the setup anyway you like it. For additional reference on troubleshooting, you can check this site. For development IDE you can either use PyCharm or Eclipse. And there is also a new CLI command --dev=all which enables developers to see the result in Odoo without upgrading the module when we change a view definition.Try setting up your own development environment and happy coding.