Understanding MVC Architecture in Odoo

October 29, 2025 by
Understanding MVC Architecture in Odoo
Widuri Sugiyani

If you’re new to Odoo development, one of the most important concepts to understand is MVC architecture — short for Model, View, and Controller. Odoo follows the MVC design pattern just like many modern web frameworks (such as Django, Laravel, or Ruby on Rails,). Knowing how it works helps you structure your modules cleanly and understand how Odoo loads, displays, and processes data.


What Is MVC in Odoo?


MVC (Model–View–Controller) is a design pattern that separates an application into three main components:

  • Model: The data layer. It manages the business logic, rules, and data of the application.
  • View: The presentation layer. It's what the user sees and interacts with (the UI).
  • Controller: The intermediary. It processes user input from the View, interacts with the Model, and selects a View to render the response.

Odoo follows this pattern but gives its components specific names and superpowers. Here’s the mapping:


The Model Layer: Python + Odoo ORM (The Brain)


This is where Odoo's power truly shines. Instead of writing raw SQL, you define your data structures as Python classes, and the Odoo ORM (Object-Relational Mapping) handles the rest.

  • What it is: Your data models (e.g., sale.order, res.partner).
  • How it's built: Python classes that inherit from models.Model.
  • The ORM's Role:
    • Auto-creates database tables based on your Python classes.
    • Provides a powerful API (search, create, write, unlink) for all CRUD operations.
    • Manages computed fields, onchanges, and constraints.
    • Handles relational fields (Many2one, One2many, Many2many) seamlessly.

from odoo import models, fields, api class LibraryBook(models.Model): _name = 'library.book' # This becomes the database table name _description = 'Library Book' # These fields become database columns​
name = fields.Char(string='Title', required=True) author = fields.Char(string='Author') date_published = fields.Date(string='Date Published') is_available = fields.Boolean(string='Is Available?')
publisher_id = fields.Many2one('res.partner', string='Publisher')

Views - The User Interface


In Odoo, the user interface is defined declaratively in XML files. These XML records tell Odoo how to display the data from the Models.

  • What it is: The structure of the web pages, forms, lists, and dashboards.
  • How it's built: XML files that define different view types. Such as tree, form, kanban, activity, etc.

<record id="view_form_library_book" model="ir.ui.view"> <field name="name">library.book.form</field> <field name="model">library.book</field> <field name="arch" type="xml"> <form> <sheet> <group> <field name="name"/> <field name="author"/> <field name="date_published"/> <field name="publisher_id"/> </group> </sheet> </form> </field> </record>

Controller — The Bridge Between Logic and UI


In Odoo, "Controllers" have a more specific meaning than in classic MVC. They handle direct web requests, typically for creating custom JSON APIs or serving specific web pages that fall outside the standard CRUD operations.

  • What it is: Handles custom HTTP routes and logic.
  • How it's built: Python classes that inherit from http.Controller and use route decorators.
  • Use Case: Creating a public API endpoint for a mobile app, generating a custom report page, or handling webhook calls from an external service.

from odoo import http from odoo.http import request class BookCatalogController(http.Controller): @http.route('/library/books/json', type='json', auth='public') def get_books_json(self): books_data = request.env['library.book'].search_read( [('is_available', '=', True)], ['name', 'author'] ) return books_data

In Odoo, a lot of the "Controller" logic from classic MVC is actually handled automatically by the framework and the ORM.When a user clicks "Save" on a form:

  1. The View (XML form) sends the data.
  2. Odoo's core framework acts as the controller. It receives the request, identifies the model (library.book), and calls the appropriate ORM method (create or write).
  3. The Model (Python class) executes the business logic (like auto-computing a field or checking a constraint).
  4. The framework then sends the updated data back to the View.


🚀 Why Understanding MVC Is Important for Odoo Developers


Knowing how MVC works in Odoo helps you:

  • Build clean, maintainable code.
  • Debug issues more effectively.
  • Extend Odoo features the “right” way.
  • Avoid mixing business logic with UI elements.
Even when building custom modules, always remember to separate logic (models), presentation (views), and interaction (controllers). 

📘 Conclusion


The MVC architecture is what makes Odoo both powerful and developer-friendly. By understanding how Models, Views, and Controllers interact, you can create structured, efficient, and easily maintainable Odoo modules.Whether you’re building your first module or improving an existing one, keeping the MVC pattern in mind will make your development process smoother and more professional.

Understanding MVC Architecture in Odoo
Widuri Sugiyani October 29, 2025
Share this post
Archive