Skip to content
Tutorials Center
My learning

Topics

Lesson 2 of 39 ยท Getting Started

Odoo Architecture

Understand Odoo's three-tier architecture: PostgreSQL, the Python server with its ORM and registry, and the web client that talks to it through JSON-RPC.

Before you write a single line of Odoo code, it helps to know which program does what. Odoo is not a monolith that hides everything from you. It has three clear tiers, and each one has a job. Once you can name them, error messages and documentation start to make sense.

This lesson draws the map: the PostgreSQL database at the bottom, the Python server in the middle, and the browser client on top. You will also see what the registry and the ORM are, because every later chapter relies on them.

The three tiers

flowchart TB
    B["Browser<br/>(web client, JavaScript)"] -->|"HTTP + JSON-RPC"| S["Odoo server<br/>(Python, ORM, controllers)"]
    S -->|"SQL via psycopg2"| D[("PostgreSQL<br/>database")]
    S --> F["Filestore<br/>(attachments on disk)"]
    S --> M["Modules<br/>(addons paths)"]

The browser never talks to PostgreSQL. All data passes through the Python server, where security is enforced.

Presentation tier: the web client. It is a JavaScript application (built on the OWL framework in recent versions) that downloads once and then calls the server. It draws forms, lists, kanban boards and charts from view definitions the server sends.

Logic tier: the Odoo server. A single Python program. It receives requests, loads your modules, runs business rules, checks access rights and talks to PostgreSQL. This is where almost all of your code lives.

Data tier: PostgreSQL. Odoo supports only PostgreSQL. Each Odoo database holds the tables of all installed modules plus data such as users and settings. Binary files, for example attachments and images, usually go into a folder on disk called the filestore, with only their references in the database.

What the server contains

Inside the Python process you find these parts:

  • Addons paths. A list of folders that contain modules. The standard apps live in odoo/addons and addons; your own work goes in a custom folder you add to the configuration.
  • The registry. For each database Odoo builds a registry: a dictionary from model names (such as res.partner) to Python classes. The registry is built when the server loads a database and is what makes inheritance work, because several modules can extend the same model into one final class.
  • The ORM. The object-relational mapping layer. You write Python classes and call methods such as search() and write(); the ORM turns them into SQL.
  • Controllers. HTTP routes for web pages and APIs.
  • Workers and cron. Background threads or processes that handle requests and scheduled jobs.

Request flow

When a user clicks a button, a call such as sale.order.action_confirm is sent as JSON-RPC to the server. The server then:

  1. Identifies the user from the session cookie.
  2. Opens a database cursor and creates an environment (user, company, context).
  3. Finds the model class in the registry and runs the method.
  4. Lets the ORM check access rights and record rules, and run SQL.
  5. Commits the transaction and returns JSON.

One request, step by step

Click Browser sends JSON-RPC
Server Registry finds the model method
Security Access rights and record rules
SQL ORM reads and writes PostgreSQL

The transaction commits at the end of the request.

1 / 2

Real code: a controller

Controllers are one entry point for the outside world. This is real Odoo code (read-only):

Python
from odoo import http


class Hello(http.Controller):
    @http.route("/hello", auth="public")
    def hello(self, **kwargs):
        return "Hello from Odoo"

auth="public" lets anyone open the page; auth="user" would require a login. Most business code is not in controllers though, but in model methods, which the web client calls directly.

A runnable stand-in: layers

The next example imitates the layering with three small functions. The "client" only knows how to call the "server"; the "server" checks permission and delegates to the "database". It is not Odoo, just the shape of the idea.

Python Stand-in: client, server and database layers

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Notice that the client never touches DATABASE. In real Odoo, this separation is why you can trust the server to enforce access rules whatever the browser sends.

Multi-database and multi-company

One Odoo server can serve several databases. Each database is a separate world with its own modules installed, its own users and its own registry. Inside a single database, multi-company lets several legal entities share one installation while keeping their records apart through record rules.

Scaling in brief

For a small installation, one server process is enough. For more load, you run Odoo in multi-worker mode behind a reverse proxy such as Nginx, and PostgreSQL may live on a separate machine. A longpolling or websocket process handles live updates like chat. Chapter 8 covers this in detail.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. Which database does Odoo support?

    Odoo is built on PostgreSQL only. The ORM generates PostgreSQL-specific SQL.
  2. 2. What is the registry?

    The registry is built when a database is loaded. It merges the contributions of all installed modules into one class per model.
  3. 3. Where does security get enforced?

    The server checks access rights and record rules for every call, so a modified browser cannot bypass them.
  4. 4. What is the filestore?

    Large binary data is saved on disk, and the database stores references to it.

Summary

  • Odoo has three tiers: a JavaScript web client, a Python server and a PostgreSQL database.
  • The server loads modules from addons paths and builds a registry of models per database.
  • The ORM translates Python method calls into SQL and enforces access rights.
  • Controllers handle HTTP routes; most business logic lives in model methods.
  • Several databases can share one server, and multi-company separates data inside one database.

Next: Community, Enterprise and Versions