To get us started with the basics of Odoo web development, we will first implement a simple Hello World
web page showcasing the basic concepts and techniques. Imaginative, right?
For our first web page, we only need a controller
object.
We will begin adding it in the controllers/hello.py
file:
- Add the following line to the
library_website/__init__.py
file:
from . import models
from . import controllers
- Add the
library_website/controllers/__init__.py
file with the following line:
from . import hello
- Add the actual file for the controller,
library_website/controllers/hello.py
, with the following code:
from odoo import http class Hello(http.Controller): @http.route('/helloworld', auth='public') def helloworld(self): return('<h1>Hello World!</h1>')
The odoo.http
module provides the Odoo web-related features. Our controllers, responsible for page rendering, should be objects that inherit from the odoo.http.Controller
class. The actual name used for...