Installing Odoo from source code
Tags: odoo, python
Published: 2023-12-19 15:45:08

In this lesson, we will go through the steps of running [Odoo](https://www.odoo.com/) (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](https://www.odoo.com/documentation/master/administration/install/source.html#).

**Prerequisite**
1. Must have [Python](https://www.python.org/downloads/) (version 3.10 or later) installed
2. Must have [PyCharm Community Edition](https://www.jetbrains.com/pycharm/download/?section=windows) installed
3. Must have [Git](https://git-scm.com/downloads) installed
4. Must have [PostgreSQL](https://www.postgresql.org/download/windows) (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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jc95iguiulfqcmqq3gab.jpg)

Enter password for postgres user. This is usually password.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/x9gl598im9dy667a2tk9.jpg)

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


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7hsn783nb93i6p2lcuy9.jpg)

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

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9152jkcsdzyz00w0jrte.jpg)

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


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3vionvactmb39zbatgcq.jpg)

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


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1a335f7nkvvyrelzixqp.jpg)



**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
```

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

```
Odoo Project/
├─ config/
│  ├─ odoo.conf
├─ custom_addons/
├─ odoo/
```
 

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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/g9j6z6u0ep3gid8ee79e.jpg)

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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fncy9i4unpt0njgoj91r.jpg)

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
```


Click File->Run->Edit Configurations. 

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xu3ck1fjf71x1vjsyr7j.jpg)

Click **Add new run configuration...**

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/48befv2g6b4ltiraqi0n.jpg)

Click **Python**

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1pmomm121fjfgy0quwc5.jpg)


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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/oa3tnok8koz8isqtyb92.jpg)

Install the dependencies using the following commands.

```
pip install setuptools wheel
pip install -r requirements.txt
```

Click the **Run Odoo** button at the top.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/14l31lx3uvdtq2bej81m.jpg)

In a browser go to [http://localhost:8069](http://localhost:8069). Enter **Database Name**, **Email** and **Password**.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ubmp1smtmffvpulcdaqm.jpg)

Log in using your credentials.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2yef6ctq049eflr0a09w.jpg)

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

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2kjcfhsysu7919uaqprz.jpg)

This concludes our lesson. For more information, check the documentation [here](https://www.odoo.com/documentation/master/administration/install/source.html#).