How to Create & Configure Web Controllers in Odoo 19

March 25, 2026 by
admin


                                                                                                                 



How to Create & Configure Web Controllers in Odoo 19
Introduction
Web controllers are a core part of Odoo’s web framework and play a critical role in how Odoo applications interact with users, browsers, and external systems. In Odoo 19, web controllers are used to define endpoints that respond to HTTP and JSON requests, making them essential for building dynamic websites, portals, public forms, integrations, and custom APIs.
Unlike standard backend actions that are triggered from the Odoo UI, web controllers allow developers to expose custom URLs that can be accessed directly through a browser or programmatically via API calls. This makes controllers the foundation for features such as website pages, customer portals, checkout flows, AJAX interactions, and third-party system integrations.
A web controller acts as the entry point for a request. When a user accesses a URL, Odoo routes the request to the corresponding controller method, where developers can:
  • Read request parameters (GET, POST, JSON)
  • Apply authentication and access rules
  • Execute business logic through Odoo models
  • Return responses such as HTML pages, redirects, or JSON data

In Odoo 19, controllers continue to follow a clean and structured design that aligns with Odoo’s MVC-inspired architecture. While models are responsible for business logic and data persistence, controllers focus strictly on request handling and response generation. Keeping this separation clear is crucial for building scalable, secure, and maintainable applications.

This document provides a detailed, step-by-step guide on how to create and configure web controllers in Odoo 19. It covers controller structure, route configuration, security considerations, and real-world examples, enabling developers to confidently implement custom web functionality in production environments.
What Is a Web Controller?
A web controller is a Python class that:
  • Listens to specific URLs (routes)
  • Processes HTTP or JSON requests
  • Interacts with Odoo models
  • Returns HTML pages, redirects, or JSON responses
Basic Controller Definition
Creating a basic web controller in Odoo 19 involves defining a Python class that inherits from odoo.http.Controller and uses the @http.route decorator to map a URL path to a method. 
  1. Define the Controller in Python
In controllers/main.py, import the necessary modules and define your controller class and method. 
     2. Create a template
Controllers usually work with a QWeb template to render HTML content. The template can display data dynamically passed from the controller.
 After installing and upgrading the module, visiting:
http://<your-domain>/my_page
will display the web page defined by the controller. The page can show dynamic content from the database, custom messages, or any HTML defined in the template.
Example: Creating a Contact List Page Using Web Controllers
To display contact information on the website, we create a web controller inside the controllers directory of our custom module. This controller defines a custom URL route and fetches contact records directly from the database. The retrieved data is then passed to a website template, allowing the contact list to be rendered dynamically on the frontend.
This controller creates a website route that allows logged-in users to view a list of customers.
In Odoo, the @http.route decorator plays a key role when creating URL routes. It is used to map a specific URL path to a controller method, defining how incoming web requests are handled. Below is a detailed breakdown of how this syntax works.
   @http.route('/customers', type='http', auth='user', website=True
Each part of the decorator has a specific purpose:
  • type = 'http'
This option specifies that the route handles standard HTTP requests, meaning it is designed to be accessed through a web browser. For API-related routes that exchange data in JSON format, the json type is commonly used instead.
  • auth = 'user'
This setting controls who is allowed to access the route. Odoo provides several authentication levels:
  • public – The page can be accessed by anyone, including users who are not logged in.
  • user – Only logged-in users can open the page.
  • bearer – Authentication is done using an API token, commonly used for secure API access.
  • none – No authentication is required, so the route is completely open.
  • website

This parameter defines whether the controller is related to the website. Setting it to True connects the route to website pages, while False is used for backend or non-website operations.

  • methods
This option restricts which HTTP methods are allowed for the route. If it is not specified, all methods are accepted by default. Commonly used methods include:
  • GET – Used to fetch data without making any changes.
  • POST – Used to send data or perform updates.
Rendering the Website View
The request.render() method is used to load a QWeb template and pass data to it:(so we can now produce a webpage to show the customer list details)

return request.render(
   'custom_module_name.customer_list_website_template',
   {'customers': customers})

Creating the Customer List View
Next, create the QWeb template inside the views folder of your module. This template is responsible for displaying the customer data on the website.
Accessing the Contact List Page and Outcome
Once the module is installed and the controller is configured, the contact list page can be accessed directly through a website URL. By navigating to the defined route (for example, http://localhost:8899/customers) in the browser, Odoo executes the corresponding controller method and renders the contact data on the website.
As a result, users are presented with a webpage that displays a list of contacts fetched from the backend database. The outcome of this implementation can be seen as a structured table view on the website, showing contact details such as name, email, and phone number, as illustrated in the screenshot below.
Web controllers in Odoo 19 are a powerful way to build dynamic websites, portals, and APIs. By correctly structuring routes, managing security, and separating concerns, you can create scalable and maintainable web features.


If you are looking for an ERP implementation partner with diverse industry experience feel free to contact us. We have proven track record of successful implementations across various sectors including Odoo for Manufacturing, Odoo for Trading, Odoo for FMCG, Odoo for Oil & Gas, Odoo for Diary, Odoo for Pharma, Odoo for Cosmetic Clinic, Odoo for Contracting Companies, Odoo for HVAC, Odoo for Logistics, Odoo for Automobile, Odoo for Laundry, Odoo for Field Service, Odoo for E-Commerce & many more
ZestyBeanz offers Developer / Consultant outsourcing programs, Chat with us in Whatsapp and Hire Odoo Developers, Mobile Application Developers, Consultants.
#OdooDevelopment #Odoo18 #CustomChatterButton #TechnicalBlog #OdooCustomization #OdooTips #Odoofeatures