SlideShare a Scribd company logo
3
Most read
5
Most read
10
Most read
URLS and routing in Odoo 18
Enterprise
Enterprise
Introduction
In Odoo 18, URLs and routing are key components of its web framework,
used to handle HTTP requests. Understanding them is essential for
customizing Odoo’s behavior, creating new pages, and integrating with
external systems.
Controllers are used to configure front-end modules under Website.
Using controllers, we can specify the URL to the link the web pages.
For that, we need to setup the controller in our module and create an xml
template to load the data in the web page.
Enterprise
Here, as an example just create a module named ‘purchase_detail’ as
follows.
Enterprise
Create a Controller in the custom module
In the directory ‘controllers’ inside the module, there are two python files
(here it’s is main.py) and __init__.py. main.py have the method with which
the data is taken from backend module to show in the website.
Enterprise
Inside main.py, import the http and http.request and create a class to write
the method. Then, use the method decorator ‘@http.route’ to navigate to a
specific page using controller
from odoo import http
from odoo.http import request
class PurchaseDetail(http.Controller):
@http.route('/purchase_detail', type='http', auth="public",
website=True)
def purchase_detail(self, **arg):
purchase_detail = request.env['purchase.order'].sudo().search([])
values = {'record' : purchase_detail}
return request.render('purchase_detail.all_purchases_data', values)
Enterprise
● For the decorator, the first parameter ‘/purchase_details’ is the URL.
● The second parameter says the type of the request. It can be http or json. Keep it as http.
json requests are used to execute methods on server to obtain result.
Type = 'http' is for responding over http request. It will take you to the another template
with the values with the dictionary passed and will refresh the page
● Third parameter gives the authentication. The values can be public, user or none.
● The last parameter website=True to make it visible on website
● Inside the method, fetch the data we need using sudo() to get data as a super user. Here
the purchase order details are taken and set as a value dictionary(‘values’ here)
● Render the template and pass the value dictionary by calling the template with the syntax
module_name. template_name
Enterprise
Create the Template
● Inside the directory ‘views’, create a new xml file to design the template to display the
data taken from backend modules.
● Inside <odoo> tag, give a unique name for the template. Keep in mind that the template
name must be the same when we render the template from the .py file.
● Design the template by keeping Odoo’s default website’s
layout using.
<template id="purchase_detail.all_purchases_data"
name="Purchases Details">
<t t-call="website.layout">
Enterprise
● Design the content using the <table>, <thead>, <tbody> tags. Here, inside the div of class
‘container’, we have to set a heading for the data to be shown, we added a table with
‘table table-striped table-dark’ class as
<br/>
<center>
<h2>PURCHASE DETAILS</h2>
</center>
<table class="table table-striped table-dark">
<thead>
<th>Purchase Order</th>
<th>Purchase Customer</th>
<th>Date</th>
<th>Amount</th>
</thead>
Enterprise
● To iterate through multiple records, <t t-foreach> can be used. Here in this example,
inside <tbody>, to get the details Purchase order Number, Customer name, Date and
Amount of each Purchase order, iterate as
<tbody>
<t t-foreach="record" t-as="po">
<tr>
<td><span t-esc="po.name"/></td>
<td><span t-esc="po.partner_id.name"/></td>
<td><span t-esc="po.date_order"/></td>
<td><span t-esc="po.amount_total"/></td>
</tr>
</t>
</tbody>
Enterprise
Open the URL from the website
Go to the website from UI and copy our URL used in the controller, ie ‘/purchase_details’ here.
The page will be loaded as below with all the details we specified using the template.
For More Info.
Check our company website for related blogs
and Odoo book.
Check our YouTube channel for
functional and technical videos in Odoo.
Enterprise
www.cybrosys.com

More Related Content

PPTX
URLs and Routing in the Odoo 17 Website App
PPTX
Building A Website - URLs and routing
PPTX
How to Add Pagination in Website portal in Odoo
PPTX
Qweb Templates and Operations in Odoo 18
PPTX
How to Create a Dynamic Snippet in Odoo 17
PPTX
How to Create a Custom Web Form View in Odoo 17
PDF
Introduction to django
PDF
Introduction to Django
URLs and Routing in the Odoo 17 Website App
Building A Website - URLs and routing
How to Add Pagination in Website portal in Odoo
Qweb Templates and Operations in Odoo 18
How to Create a Dynamic Snippet in Odoo 17
How to Create a Custom Web Form View in Odoo 17
Introduction to django
Introduction to Django

Similar to URLS and routing in odoo 18 - Odoo Slides (20)

PPTX
How to Create a Theme Module in Odoo 17 - Odoo 17 Slides
PPTX
How to Create & Manage a Dashboard Using OWL in Odoo 17
KEY
Introduction Django
PPTX
How to add menu in Odoo 17 Website - Odoo 17 Slides
PPTX
How to Store Data on the Odoo 17 Website
PDF
Django cheat sheet
PPTX
How to add Many2Many fields in odoo website form.pptx
PPTX
How to Create a PDF Report in Odoo 18 - Odoo Slides
PPTX
How to Install Custom Module in Odoo 17 - Odoo 17 Slides
PDF
PPTX
Polymer 3.0 by Michele Gallotti
PDF
A Basic Django Introduction
PPTX
How to Add Sort Option in Website Portal Odoo 17
PDF
Django 1.10.3 Getting started
PPTX
Client Actions In Odoo 17 - Odoo 17 Slides
PPTX
Creating Single Page Web App using Backbone JS
PDF
Get things done with Yii - quickly build webapplications
PPTX
Django crush course
PPTX
How to Build a Module in Odoo 15 Scaffold Method
PDF
Mini Curso de Django
How to Create a Theme Module in Odoo 17 - Odoo 17 Slides
How to Create & Manage a Dashboard Using OWL in Odoo 17
Introduction Django
How to add menu in Odoo 17 Website - Odoo 17 Slides
How to Store Data on the Odoo 17 Website
Django cheat sheet
How to add Many2Many fields in odoo website form.pptx
How to Create a PDF Report in Odoo 18 - Odoo Slides
How to Install Custom Module in Odoo 17 - Odoo 17 Slides
Polymer 3.0 by Michele Gallotti
A Basic Django Introduction
How to Add Sort Option in Website Portal Odoo 17
Django 1.10.3 Getting started
Client Actions In Odoo 17 - Odoo 17 Slides
Creating Single Page Web App using Backbone JS
Get things done with Yii - quickly build webapplications
Django crush course
How to Build a Module in Odoo 15 Scaffold Method
Mini Curso de Django
Ad

More from Celine George (20)

PPTX
How to Implement OWL Notification Service in Odoo 18
PPTX
Tracking Profit Margins in Sales Orders with Odoo 18
PPTX
How to Configure Outgoing Shipment in 3 Steps Using Odoo 18
PPTX
How to Configure Outgoing Shipment in 1 Step Using Odoo 18.pptx
PPTX
How to Configure Outgoing Shipment in 2 Steps Using Odoo 18
PPTX
How to Add New Applicants in Odoo 18 Recruitment
PPTX
How to Analyze the Recruitment Process in Odoo 18 Recruitment
PPTX
How to Manage Referral Reporting in Odoo 18 Referrals
PPTX
How to Set, Track, & Review Employee Goals in Odoo 18 Appraisals
PPTX
Revamp in MTO Odoo 18 Inventory - Odoo Slides
PPTX
How to Manage Starshipit in Odoo 18 - Odoo Slides
PPTX
How to Manage Bill Control Policy in Odoo 18
PPTX
How to Manage Loyalty Points in Odoo 18 Sales
PPTX
Odoo 18 Sales_ Managing Quotation Validity
PPTX
How to Manage Global Discount in Odoo 18 POS
PPTX
How to Manage Leads in Odoo 18 CRM - Odoo Slides
PPTX
Tips Management in Odoo 18 POS - Odoo Slides
PPTX
How to Close Subscription in Odoo 18 - Odoo Slides
PPTX
Kanban Cards _ Mass Action in Odoo 18.2 - Odoo Slides
PPTX
How to Track Skills & Contracts Using Odoo 18 Employee
How to Implement OWL Notification Service in Odoo 18
Tracking Profit Margins in Sales Orders with Odoo 18
How to Configure Outgoing Shipment in 3 Steps Using Odoo 18
How to Configure Outgoing Shipment in 1 Step Using Odoo 18.pptx
How to Configure Outgoing Shipment in 2 Steps Using Odoo 18
How to Add New Applicants in Odoo 18 Recruitment
How to Analyze the Recruitment Process in Odoo 18 Recruitment
How to Manage Referral Reporting in Odoo 18 Referrals
How to Set, Track, & Review Employee Goals in Odoo 18 Appraisals
Revamp in MTO Odoo 18 Inventory - Odoo Slides
How to Manage Starshipit in Odoo 18 - Odoo Slides
How to Manage Bill Control Policy in Odoo 18
How to Manage Loyalty Points in Odoo 18 Sales
Odoo 18 Sales_ Managing Quotation Validity
How to Manage Global Discount in Odoo 18 POS
How to Manage Leads in Odoo 18 CRM - Odoo Slides
Tips Management in Odoo 18 POS - Odoo Slides
How to Close Subscription in Odoo 18 - Odoo Slides
Kanban Cards _ Mass Action in Odoo 18.2 - Odoo Slides
How to Track Skills & Contracts Using Odoo 18 Employee
Ad

Recently uploaded (20)

PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PPTX
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
O5-L3 Freight Transport Ops (International) V1.pdf
PDF
RMMM.pdf make it easy to upload and study
PPTX
Microbial diseases, their pathogenesis and prophylaxis
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PDF
TR - Agricultural Crops Production NC III.pdf
PPTX
Renaissance Architecture: A Journey from Faith to Humanism
PPTX
Cell Structure & Organelles in detailed.
PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PPTX
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
PDF
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
PPTX
Cell Types and Its function , kingdom of life
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PDF
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
Module 4: Burden of Disease Tutorial Slides S2 2025
2.FourierTransform-ShortQuestionswithAnswers.pdf
Final Presentation General Medicine 03-08-2024.pptx
O5-L3 Freight Transport Ops (International) V1.pdf
RMMM.pdf make it easy to upload and study
Microbial diseases, their pathogenesis and prophylaxis
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
TR - Agricultural Crops Production NC III.pdf
Renaissance Architecture: A Journey from Faith to Humanism
Cell Structure & Organelles in detailed.
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
Cell Types and Its function , kingdom of life
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape

URLS and routing in odoo 18 - Odoo Slides

  • 1. URLS and routing in Odoo 18 Enterprise
  • 2. Enterprise Introduction In Odoo 18, URLs and routing are key components of its web framework, used to handle HTTP requests. Understanding them is essential for customizing Odoo’s behavior, creating new pages, and integrating with external systems. Controllers are used to configure front-end modules under Website. Using controllers, we can specify the URL to the link the web pages. For that, we need to setup the controller in our module and create an xml template to load the data in the web page.
  • 3. Enterprise Here, as an example just create a module named ‘purchase_detail’ as follows.
  • 4. Enterprise Create a Controller in the custom module In the directory ‘controllers’ inside the module, there are two python files (here it’s is main.py) and __init__.py. main.py have the method with which the data is taken from backend module to show in the website.
  • 5. Enterprise Inside main.py, import the http and http.request and create a class to write the method. Then, use the method decorator ‘@http.route’ to navigate to a specific page using controller from odoo import http from odoo.http import request class PurchaseDetail(http.Controller): @http.route('/purchase_detail', type='http', auth="public", website=True) def purchase_detail(self, **arg): purchase_detail = request.env['purchase.order'].sudo().search([]) values = {'record' : purchase_detail} return request.render('purchase_detail.all_purchases_data', values)
  • 6. Enterprise ● For the decorator, the first parameter ‘/purchase_details’ is the URL. ● The second parameter says the type of the request. It can be http or json. Keep it as http. json requests are used to execute methods on server to obtain result. Type = 'http' is for responding over http request. It will take you to the another template with the values with the dictionary passed and will refresh the page ● Third parameter gives the authentication. The values can be public, user or none. ● The last parameter website=True to make it visible on website ● Inside the method, fetch the data we need using sudo() to get data as a super user. Here the purchase order details are taken and set as a value dictionary(‘values’ here) ● Render the template and pass the value dictionary by calling the template with the syntax module_name. template_name
  • 7. Enterprise Create the Template ● Inside the directory ‘views’, create a new xml file to design the template to display the data taken from backend modules. ● Inside <odoo> tag, give a unique name for the template. Keep in mind that the template name must be the same when we render the template from the .py file. ● Design the template by keeping Odoo’s default website’s layout using. <template id="purchase_detail.all_purchases_data" name="Purchases Details"> <t t-call="website.layout">
  • 8. Enterprise ● Design the content using the <table>, <thead>, <tbody> tags. Here, inside the div of class ‘container’, we have to set a heading for the data to be shown, we added a table with ‘table table-striped table-dark’ class as <br/> <center> <h2>PURCHASE DETAILS</h2> </center> <table class="table table-striped table-dark"> <thead> <th>Purchase Order</th> <th>Purchase Customer</th> <th>Date</th> <th>Amount</th> </thead>
  • 9. Enterprise ● To iterate through multiple records, <t t-foreach> can be used. Here in this example, inside <tbody>, to get the details Purchase order Number, Customer name, Date and Amount of each Purchase order, iterate as <tbody> <t t-foreach="record" t-as="po"> <tr> <td><span t-esc="po.name"/></td> <td><span t-esc="po.partner_id.name"/></td> <td><span t-esc="po.date_order"/></td> <td><span t-esc="po.amount_total"/></td> </tr> </t> </tbody>
  • 10. Enterprise Open the URL from the website Go to the website from UI and copy our URL used in the controller, ie ‘/purchase_details’ here. The page will be loaded as below with all the details we specified using the template.
  • 11. For More Info. Check our company website for related blogs and Odoo book. Check our YouTube channel for functional and technical videos in Odoo. Enterprise www.cybrosys.com