SlideShare a Scribd company logo
4
Most read
6
Most read
7
Most read
How to Add Pagination in
Website portal in Odoo
Enterprise
Introduction
Enterprise
In the context of an Odoo website portal, pagination refers to the
process of dividing a large set of records into smaller, more
manageable pages and providing navigation controls to move
between these pages. This is essential for enhancing the user
experience by preventing long loading times and making data
presentation more manageable.
Odoo provides the feature to manage website pagination by default.
For that you have to render the pager values in the controller
Enterprise
Controllers
Controllers are responsible for defining the routes (URLs) that the
application responds to, executing the necessary business logic, and
rendering the appropriate views or templates. Create a Python file in
your module, typically in the controllers directory, and define a
controller class. Use the http.Controller class from Odoo’s web
framework.
Controllers' are utilized to arrange the frontend modules which are
incorporated with backend modules.
Edit your controller to support pagination by adding parameters.
Enterprise
The code for the controller main.py file can be set as
class MyPortal(http.Controller):
@http.route(['/customer','/customer/page/<int:page>'],type="http",auth="user",website=True)
def customer_kanban(self, page=0, search='', **post):
Domain = []
if search:
domain.append(('name', 'ilike', search))
if search:
post["search"] = search
customer_obj = request.env['res.partner'].sudo().search(domain)
total = customer_obj.sudo().search_count([])
pager = request.website.pager(
url='/customer',
total=total,
page=page,
step=3,
)
Enterprise
Here, The request.website.pager() method in Odoo is used to create
pagination controls for listing records on a web page. This method
generates the necessary pagination data, such as the total number of
pages, the current page, and the URLs for navigating between pages.
We can pass the required parameters, some of the parameters are as
follows ,
● url: base url of the page link
● total: number total of item to be splitted into pages
● page: current page
● step: item per page
● scope: number of page to display on pager
● url_args: additional parameters to add as query params to page
url
Enterprise
The offset key within the pager dictionary can be used to calculate the
starting point for fetching records from the database. It represents the
position in the dataset from which to start retrieving records for the current
page.
offset = pager['offset']
customer_obj = customer_obj[offset: offset + 5]
return request.render('customer_website.customer_form', {
'search': search,
'customer_details': customer_obj,
'pager': pager,
})
Enterprise
Now, <t t-call="website.pager"> is used to render pagination links (like
previous, next, and specific page numbers) on your web page, making it
easier to navigate through paginated data. This ensures that your web
pages have consistent and functional pagination controls, improving the
user experience when navigating through large datasets.
To display the pagination inside the website, include this in the template
<div class="products_pager form-inline justify-content-center mt-3">
<t t-call="website.pager">
<t t-set="_classes">mt-2 ml-md-2</t>
</t>
</div>
Enterprise
And for the template customer_form for displaying all the customers in our
website along with the pagination at the bottom, call the website.layout, and
start designing the form
<template id="customer_form" name="Customers">
<t t-call="website.layout">
<div>
<div class="col-md-6">
<br/>
<div>
<form action="/customer" method="post">
<t t-call="website.website_search_box">
</t>
<input type="hidden" name="csrf_token" t-att-
value="request.csrf_token()"/>
Enterprise
Under the <section>, design to show the customer details
<section><div class="customer_details"><center>
<h3>Customers</h3></center></div><br/>
<div class="oe_product_cart_new row" style="overflow: hidden;">
<t t-foreach="customer_details" t-as="customers">
<div class="col-md-3 col-sm-3 col-xs-12" style="padding:1px 1px 1px 1px;">
<div style="border: 1px solid #f0eaea;width: 150px;height: auto;padding: 7% 0% 10% 0%;
border-radius: 3px;overflow: hidden;margin-bottom: 44px;width: 100%;height: 100%;">
<div class="oe_product_image">
<center>
<div style="width:100%;overflow: hidden;">
<img t-if="customers.image_1920" t-attf-src="/web/image/res.partner/#{customers.id}/image_1920"
class="img oe_product_image" style="padding: 0px; margin: 0px; width:auto; height:100%;"/> </div>
<div style="text-align: left;margin: 10px 15px 3px 15px;">
<t t-if="customers.name"><span t-esc="customers.name" style="font-weight: bolder;color:
#3e3b3b;"/><br/></t></div></center></div></div></div></t></div>
Enterprise
After that, put the code for the pagination that we mentioned earlier.
By implementing pagination, you enhance the performance, scalability,
and user experience of your Odoo application. Users benefit from
faster load times, easier navigation, and a cleaner interface, while
developers gain control and efficiency in managing large datasets.
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 odoo 18 - Odoo Slides
PPTX
URLs and Routing in the Odoo 17 Website App
PPTX
SMX Advanced: Thriving in the New World of Pagination
PPTX
How to Modify Existing Web Pages in Odoo 18
PPTX
FastView acceleration overview
PDF
Client-side Web Performance Optimization [paper]
DOCX
Inventory management system
ODP
A Holistic View of Website Performance
URLS and routing in odoo 18 - Odoo Slides
URLs and Routing in the Odoo 17 Website App
SMX Advanced: Thriving in the New World of Pagination
How to Modify Existing Web Pages in Odoo 18
FastView acceleration overview
Client-side Web Performance Optimization [paper]
Inventory management system
A Holistic View of Website Performance

Similar to How to Add Pagination in Website portal in Odoo (20)

DOC
E space abstract
PDF
online shopping
PDF
Project report Rs Dry celaners
PDF
Cloud Performance: Guide to Tackling Cloud Latency [Cloud Connect - Chicago 2...
DOC
171846965 projects
PPTX
Cloud Connect Santa Clara 2013: Web Acceleration and Front-End Optimization (...
PPTX
Ecommerce website with seo optimization
PPTX
E-Bazaar
PDF
Intro to-rails-webperf
PDF
7 secrets of performance oriented front end development services
DOCX
Coding part
PDF
PyGrunn2013 High Performance Web Applications with TurboGears
PPTX
SEO Pagination - The Ultimate Guide (aka "Gettin' Jiggy Wit It")
PDF
RemoteStaff Design Solutions Rate card
PPTX
Thank U (Rel) Next - State of Retail Pagination 1Y Later - Orit Mutznik - Bri...
PDF
E-commerce Proposal
PDF
Odoo Functional Training
PPTX
Enhancing the User Experience
PPTX
Products and Categories
PDF
The ultimate guide to creating the perfect website
E space abstract
online shopping
Project report Rs Dry celaners
Cloud Performance: Guide to Tackling Cloud Latency [Cloud Connect - Chicago 2...
171846965 projects
Cloud Connect Santa Clara 2013: Web Acceleration and Front-End Optimization (...
Ecommerce website with seo optimization
E-Bazaar
Intro to-rails-webperf
7 secrets of performance oriented front end development services
Coding part
PyGrunn2013 High Performance Web Applications with TurboGears
SEO Pagination - The Ultimate Guide (aka "Gettin' Jiggy Wit It")
RemoteStaff Design Solutions Rate card
Thank U (Rel) Next - State of Retail Pagination 1Y Later - Orit Mutznik - Bri...
E-commerce Proposal
Odoo Functional Training
Enhancing the User Experience
Products and Categories
The ultimate guide to creating the perfect website
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)

PDF
Supply Chain Operations Speaking Notes -ICLT Program
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PDF
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
PDF
Microbial disease of the cardiovascular and lymphatic systems
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PPTX
Lesson notes of climatology university.
PPTX
Renaissance Architecture: A Journey from Faith to Humanism
PPTX
PPH.pptx obstetrics and gynecology in nursing
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PDF
TR - Agricultural Crops Production NC III.pdf
PDF
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PDF
Complications of Minimal Access Surgery at WLH
PPTX
GDM (1) (1).pptx small presentation for students
PDF
RMMM.pdf make it easy to upload and study
PPTX
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
Supply Chain Operations Speaking Notes -ICLT Program
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
Microbial disease of the cardiovascular and lymphatic systems
FourierSeries-QuestionsWithAnswers(Part-A).pdf
human mycosis Human fungal infections are called human mycosis..pptx
Final Presentation General Medicine 03-08-2024.pptx
STATICS OF THE RIGID BODIES Hibbelers.pdf
Lesson notes of climatology university.
Renaissance Architecture: A Journey from Faith to Humanism
PPH.pptx obstetrics and gynecology in nursing
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
TR - Agricultural Crops Production NC III.pdf
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
Module 4: Burden of Disease Tutorial Slides S2 2025
Complications of Minimal Access Surgery at WLH
GDM (1) (1).pptx small presentation for students
RMMM.pdf make it easy to upload and study
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...

How to Add Pagination in Website portal in Odoo

  • 1. How to Add Pagination in Website portal in Odoo Enterprise
  • 2. Introduction Enterprise In the context of an Odoo website portal, pagination refers to the process of dividing a large set of records into smaller, more manageable pages and providing navigation controls to move between these pages. This is essential for enhancing the user experience by preventing long loading times and making data presentation more manageable. Odoo provides the feature to manage website pagination by default. For that you have to render the pager values in the controller
  • 3. Enterprise Controllers Controllers are responsible for defining the routes (URLs) that the application responds to, executing the necessary business logic, and rendering the appropriate views or templates. Create a Python file in your module, typically in the controllers directory, and define a controller class. Use the http.Controller class from Odoo’s web framework. Controllers' are utilized to arrange the frontend modules which are incorporated with backend modules. Edit your controller to support pagination by adding parameters.
  • 4. Enterprise The code for the controller main.py file can be set as class MyPortal(http.Controller): @http.route(['/customer','/customer/page/<int:page>'],type="http",auth="user",website=True) def customer_kanban(self, page=0, search='', **post): Domain = [] if search: domain.append(('name', 'ilike', search)) if search: post["search"] = search customer_obj = request.env['res.partner'].sudo().search(domain) total = customer_obj.sudo().search_count([]) pager = request.website.pager( url='/customer', total=total, page=page, step=3, )
  • 5. Enterprise Here, The request.website.pager() method in Odoo is used to create pagination controls for listing records on a web page. This method generates the necessary pagination data, such as the total number of pages, the current page, and the URLs for navigating between pages. We can pass the required parameters, some of the parameters are as follows , ● url: base url of the page link ● total: number total of item to be splitted into pages ● page: current page ● step: item per page ● scope: number of page to display on pager ● url_args: additional parameters to add as query params to page url
  • 6. Enterprise The offset key within the pager dictionary can be used to calculate the starting point for fetching records from the database. It represents the position in the dataset from which to start retrieving records for the current page. offset = pager['offset'] customer_obj = customer_obj[offset: offset + 5] return request.render('customer_website.customer_form', { 'search': search, 'customer_details': customer_obj, 'pager': pager, })
  • 7. Enterprise Now, <t t-call="website.pager"> is used to render pagination links (like previous, next, and specific page numbers) on your web page, making it easier to navigate through paginated data. This ensures that your web pages have consistent and functional pagination controls, improving the user experience when navigating through large datasets. To display the pagination inside the website, include this in the template <div class="products_pager form-inline justify-content-center mt-3"> <t t-call="website.pager"> <t t-set="_classes">mt-2 ml-md-2</t> </t> </div>
  • 8. Enterprise And for the template customer_form for displaying all the customers in our website along with the pagination at the bottom, call the website.layout, and start designing the form <template id="customer_form" name="Customers"> <t t-call="website.layout"> <div> <div class="col-md-6"> <br/> <div> <form action="/customer" method="post"> <t t-call="website.website_search_box"> </t> <input type="hidden" name="csrf_token" t-att- value="request.csrf_token()"/>
  • 9. Enterprise Under the <section>, design to show the customer details <section><div class="customer_details"><center> <h3>Customers</h3></center></div><br/> <div class="oe_product_cart_new row" style="overflow: hidden;"> <t t-foreach="customer_details" t-as="customers"> <div class="col-md-3 col-sm-3 col-xs-12" style="padding:1px 1px 1px 1px;"> <div style="border: 1px solid #f0eaea;width: 150px;height: auto;padding: 7% 0% 10% 0%; border-radius: 3px;overflow: hidden;margin-bottom: 44px;width: 100%;height: 100%;"> <div class="oe_product_image"> <center> <div style="width:100%;overflow: hidden;"> <img t-if="customers.image_1920" t-attf-src="/web/image/res.partner/#{customers.id}/image_1920" class="img oe_product_image" style="padding: 0px; margin: 0px; width:auto; height:100%;"/> </div> <div style="text-align: left;margin: 10px 15px 3px 15px;"> <t t-if="customers.name"><span t-esc="customers.name" style="font-weight: bolder;color: #3e3b3b;"/><br/></t></div></center></div></div></div></t></div>
  • 10. Enterprise After that, put the code for the pagination that we mentioned earlier. By implementing pagination, you enhance the performance, scalability, and user experience of your Odoo application. Users benefit from faster load times, easier navigation, and a cleaner interface, while developers gain control and efficiency in managing large datasets.
  • 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