Adding an HTTP Controller Route in Odoo

A controller route is a web endpoint Odoo responds to. How a developer adds one.

Odoo responds to web requests, and a controller route is a web endpoint it responds to. This piece is about adding an HTTP controller route in Odoo.

What a controller route is

A controller route, in Odoo, is a defined web endpoint that Odoo responds to: a particular web address that, when a request comes to it, Odoo handles, doing something and responding. Routes are how Odoo's web-facing functionality is built: a route is defined, and when a request comes to that route, the code attached to it runs and produces the response. A developer building web-facing functionality, anything Odoo does in response to a web request, works with controller routes.

Where controllers fit

Controller routes live in a module's controllers, the part of a module for the web-facing code. A developer building functionality that responds to web requests, a web page served, a web form handled, a web endpoint other software can call, defines the controller routes for it. The controller is the web-facing layer of a module, and adding a controller route is adding a web endpoint to it.

Adding a controller route

A developer adds a controller route by defining it in a module's controllers: defining the route, the web address it responds to, and the code that handles a request to it and produces a response. Adding the route is, in essence, declaring "Odoo should respond to requests at this web address, and here is what it should do". Once the route is added, Odoo responds to requests to that address with the developer's code.

Routes and what they are for

Controller routes are the basis of a range of web-facing things a developer might build. A route can serve a web page. A route can handle the submission of a web form. A route can be a web endpoint that other software calls, which connects to the matter of building web-facing interfaces for integration. So adding a controller route is a foundational step for web-facing functionality of various kinds; the route is the web endpoint, and what the route does is what the developer builds.

Routes have to be considered for security

An honest, important note. A controller route is a web endpoint, something reachable over the web, and a web endpoint has to be considered for security. A route that should only be reachable by the right people has to be secured so that it is; a route that is genuinely public is reachable by anyone. A developer adding a controller route must consider its security, who should be able to reach it, and ensure the route is appropriately secured. Securing controller routes is significant enough to consider in its own right, but the point here is that a developer adding a route must not add it without considering its security.

The takeaway

Adding an HTTP controller route in Odoo defines a web endpoint that Odoo responds to: a web address that, when a request comes to it, Odoo handles with the developer's code. Controller routes live in a module's controllers and are the basis of web-facing functionality, serving a page, handling a form, being an endpoint other software calls. A developer adds a route by defining it and the code that handles requests to it. A route is a web endpoint, so its security must be considered. For how we approach Odoo, see our ERP practice.

All posts

Got a Topic Worth Posting?

Suggest a Topic

If a question keeps coming up in your operations, it might be worth its own post.