DEV Community

David Akim
David Akim

Posted on

Installing Odoo from source code

In this lesson, we will go through the steps of running Odoo (Community version) in Windows from the source code. Odoo is an open-source business management software suite that includes a range of business applications for various purposes such as accounting, inventory management, and customer relationship management (CRM). We will be using the PyCharm IDE. To run Odoo in other operating systems, please check the documentation here.

Prerequisite

  1. Must have Python (version 3.10 or later) installed
  2. Must have PyCharm Community Edition installed
  3. Must have Git installed
  4. Must have PostgreSQL (version 12.0 or later) installed

Add PostgreSQL’s bin directory to the Environment variables

  1. Launch Control Panel
  2. Click System and Security
  3. Click System
  4. Click Advance System Settings
  5. Click Environment Variables...
  6. If you want to make this path available to you alone, click New... under User variables. If you want to make this path available to everyone, click New... under System variables
  7. Variable name is Path and Variable value is the PostgreSQL’s bin directory (by default: C:\Program Files\PostgreSQL<version>\bin) (Note: If this variable already exists, click Edit... instead of New...)

Create a new PostgreSQL user
Open the pg admin gui (pgAdmin 4). Enter master password or click Reset Master Password if you forgot the password.

Image description

Enter password for postgres user. This is usually password.

Image description

Navigate to Login/Group Roles. Right click and select Create->Login/Group Role.

Image description

In the General tab, give the role a Name. In this example Name is odoo_user. (Remember this)

Image description

In the Definition tab, fill out the Password field. (Remember this)

Image description

In the Privileges tab, enable Can login? and Create databases?. Click Save.

Image description

Setting up project folder

Create a folder called Odoo Project (you can give this folder any name)

Inside this folder create a folder called config and another folder called custom_addons.

Inside the config folder, create a file called odoo.conf.

Open a command terminal and navigate to Odoo Project folder.

In the Odoo Project directory, clone the Odoo source code Git repository with the following command.

git clone https://github.com/odoo/odoo.git
Enter fullscreen mode Exit fullscreen mode

At this point, your folder structure should look like this.

Odoo Project/
├─ config/
│  ├─ odoo.conf
├─ custom_addons/
├─ odoo/
Enter fullscreen mode Exit fullscreen mode

Copy the requirements.txt in odoo folder and paste in the Odoo Project folder.

Setting up Pycharm
Open PyCharm and click New Project.

Image description

Select the location of your project. Check the option New environment using Virtualenv. You can leave the location of the environment as it is. Select the location of python.exe for the Base interpreter. Click Create.

Image description

We need to give Odoo our database information: user, password, host and port. The db_user and db_password created earlier (Create a new PostgreSQL user section). We also need to give Odoo the location of our custom_addons folder (addons_path).
On the Project Panel, open the odoo.conf file and copy the contents below.

[options]
addons_path = G:\Projects\Odoo\Odoo Project\custom_addons
db_user = odoo_user
db_password = odoo_user
db_host = localhost
db_port = 5432
Enter fullscreen mode Exit fullscreen mode

Click File->Run->Edit Configurations.

Image description

Click Add new run configuration...

Image description

Click Python

Image description

Set the Name to Odoo. Set Script Path to the odoo-bin file. This is located inside the odoo folder which is inside the Odoo Project folder. Set Parameters to -c config/odoo.conf. Set Working Directory to the Odoo Project folder. Click Apply and OK.

Click Terminal at the bottom left.

Image description

Install the dependencies using the following commands.

pip install setuptools wheel
pip install -r requirements.txt
Enter fullscreen mode Exit fullscreen mode

Click the Run Odoo button at the top.

Image description

In a browser go to http://localhost:8069. Enter Database Name, Email and Password.

Image description

Log in using your credentials.

Image description

You will now be logged in. Here you can activate your required applications.

Image description

This concludes our lesson. For more information, check the documentation here.

Top comments (0)