ºÝºÝߣ

ºÝºÝߣShare a Scribd company logo
How to Modify Existing Web Pages in
Odoo 18
Enterprise
Enterprise
Introduction
In this slide, we’ll discuss on how to modify existing web pages
in Odoo 18. Web pages in Odoo 18 can also gather user data
through user-friendly forms, encourage interaction through
engaging features. However, through strategic modifications, we
can transform this virtual real estate into a captivating showcase
that captures visitors attention and propels them further into
the sales funnel.
Enterprise
Before adding the custom code in controller, we can add custom
field in product_template model.
from odoo import fields, models
class ProductTemplate(models.Model):
_inherit = 'product.template'
top_selling = fields.Boolean(string='Top selling')
Next, to add this in the view, we can inherit the product_template
model and add the field.
Enterprise
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<record id="product_template_form_view"
model="ir.ui.view">
<field
name="name">product.template.inherit.view.form</field>
<field name="model">product.template</field>
<field name="inherit_id"
ref="product.product_template_form_view"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='taxes_id']"
position="after">
<field name="top_selling"/>
</xpath>
</field>
</record>
</odoo>
Enterprise
Next, to add top selling products of the e-commerce website on the
Home Page, we can use the code snippet to fetch the top-selling
products based on their sales count within a specified date range and
renders them on the homepage of the website. homepage template. We
can add this code in the controller of the custom module.
from odoo import http
from odoo.http import request
from odoo.addons.website.controllers.main import Home
class Website(Home):
@http.route('/', auth="public", website=True,
sitemap=True)
def index(self, **kw):
"""Initialize products' sales count and top-
selling flag"""
products =
request.env['product.template'].sudo().search([])
Enterprise
for product in products:
product.sales_count = 0
product.top_selling = False
orders = request.env['sale.order'].sudo().search([
('state', 'in', ('sale', 'done'))])
for order in orders:
for line in order.order_line:
line.product_id.sales_count +=
line.product_uom_qty
website_product_ids = [product for product in
products if product.sales_count != 0]
sorted_products = sorted(website_product_ids,
key=lambda p: p.sales_count, reverse=True)
# Mark the top 4 products as top-selling
for product in sorted_products[3:7]:
product.top_selling = True
Enterprise
# Render the homepage template with the sorted
products
return request.render(
'website.homepage',
{'website_product_ids': sorted_products[3:7]})
To incorporate these top-selling products into the homepage, we can
inherit the website. Create a homepage template and add a container
within the div with the ID wrap.
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<template id="homepage_inherit_product_display"
inherit_id="website.homepage" name="Products"
active="True">
<data inherit_id="website.homepage">
<xpath expr="//div[@id='wrap']"
position="inside">
<input type="hidden" name="csrf_token" t-
att-value="request.csrf_token()"/>
Enterprise
<div class="container mt32 mb64">
<section>
<div class="product_details">
<center>
<h3>MOST SELLING
PRODUCTS</h3>
</center>
</div>
<br/>
<div class="oe_product_cart_new row"
style="overflow: hidden;">
<t t-
foreach="website_product_ids"
t-as="website_product_id">
<div class="col-md-3 col-sm-3
col-xs-12" style="padding:6px 6px 6px 6px;">
<form
action="/shop/cart/update" method="post" class="card
oe_product_cart" data-publish="on">
<br/>
<center>
Enterprise
<div style="width:100%;
height:155px;overflow: hidden;">
<a
t-attf-href="/shop/product/#{ slug(website_product_id) }">
<img
t-attf-src=/slideshow/how-to-modify-existing-web-pages-in-odoo-18/276332419/"/web/image
model=product.template&amp;field=image_1920&amp;id=#{websit
e_product_id.id}" class="img img-fluid"
style="padding: 0px; margin:
0px; width:auto; height:100%;"/>
</a>
</div>
</center>
<br/>
<div class="card-body p-0 text-center
o_wsale_product_information">
<div class="p-2
o_wsale_product_information_text">
<h6 class="o_wsale_products_item_title">
Enterprise
<a data-oe-model="product.template" data-oe-
id="website_product_id.id"
data-oe-field="website_product_id.name"
data-oe-type="char"
data-oe-
expression="product.name"
itemprop="name"
data-oe-field-xpath="/t[1]/form[1]/div[2]/div[1]/h6[1]/a[1]
" t-attf-
href="/shop/product/#{ slug(website_product_id) }"
content="website_product_id.name">
<t t-
esc="website_product_id.name"/>
</a>
</h6>
<h6 class="o_wsale_products_item_title">
<span t-
esc="website_product_id.currency_id.symbol"
style="color:black"/>
<t t-esc="website_product_id.list_price"/>
</h6>
</div>
Enterprise
<div class="o_wsale_product_btn"
data-oe-model="ir.ui.view"
data-oe-id="1561" data-oe-
field="arch" data-oe-
xpath="/t[1]/form[1]/div[2]/div[2]"/>
</div>
<span class="o_ribbon " style=""/>
</form>
</div>
</t>
</div>
</section>
</div>
</xpath>
</data>
</template>
</odoo>
Enterprise
This code snippet iterates over the top-selling products and displays
their name, image, and price within a product cart view on the
homepage.
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

More from Celine George (20)

How to Configure Flexible Working Schedule in Odoo 18 Employee
How to Configure Flexible Working Schedule in Odoo 18 EmployeeHow to Configure Flexible Working Schedule in Odoo 18 Employee
How to Configure Flexible Working Schedule in Odoo 18 Employee
Celine George
Ìý
Managing expiration dates of products in odoo
Managing expiration dates of products in odooManaging expiration dates of products in odoo
Managing expiration dates of products in odoo
Celine George
Ìý
How to Unblock Payment in Odoo 18 Accounting
How to Unblock Payment in Odoo 18 AccountingHow to Unblock Payment in Odoo 18 Accounting
How to Unblock Payment in Odoo 18 Accounting
Celine George
Ìý
How to Configure Proforma Invoice in Odoo 18 Sales
How to Configure Proforma Invoice in Odoo 18 SalesHow to Configure Proforma Invoice in Odoo 18 Sales
How to Configure Proforma Invoice in Odoo 18 Sales
Celine George
Ìý
How to Configure Deliver Content by Email in Odoo 18 Sales
How to Configure Deliver Content by Email in Odoo 18 SalesHow to Configure Deliver Content by Email in Odoo 18 Sales
How to Configure Deliver Content by Email in Odoo 18 Sales
Celine George
Ìý
Effective Product Variant Management in Odoo 18
Effective Product Variant Management in Odoo 18Effective Product Variant Management in Odoo 18
Effective Product Variant Management in Odoo 18
Celine George
Ìý
How to create security group category in Odoo 17
How to create security group category in Odoo 17How to create security group category in Odoo 17
How to create security group category in Odoo 17
Celine George
Ìý
Odoo 18 Accounting Access Rights - Odoo 18 ºÝºÝߣs
Odoo 18 Accounting Access Rights - Odoo 18 ºÝºÝߣsOdoo 18 Accounting Access Rights - Odoo 18 ºÝºÝߣs
Odoo 18 Accounting Access Rights - Odoo 18 ºÝºÝߣs
Celine George
Ìý
Inventory Reporting in Odoo 17 - Odoo 17 Inventory App
Inventory Reporting in Odoo 17 -  Odoo 17 Inventory AppInventory Reporting in Odoo 17 -  Odoo 17 Inventory App
Inventory Reporting in Odoo 17 - Odoo 17 Inventory App
Celine George
Ìý
How to Configure Recurring Revenue in Odoo 17 CRM
How to Configure Recurring Revenue in Odoo 17 CRMHow to Configure Recurring Revenue in Odoo 17 CRM
How to Configure Recurring Revenue in Odoo 17 CRM
Celine George
Ìý
One Click RFQ Cancellation in Odoo 18 - Odoo ºÝºÝߣs
One Click RFQ Cancellation in Odoo 18 - Odoo ºÝºÝߣsOne Click RFQ Cancellation in Odoo 18 - Odoo ºÝºÝߣs
One Click RFQ Cancellation in Odoo 18 - Odoo ºÝºÝߣs
Celine George
Ìý
How to Create Meetings & Channels in Odoo 18 Discuss
How to Create Meetings & Channels in Odoo 18 DiscussHow to Create Meetings & Channels in Odoo 18 Discuss
How to Create Meetings & Channels in Odoo 18 Discuss
Celine George
Ìý
How to Configure Canned Response & Chatbots in Odoo 18
How to Configure Canned Response & Chatbots in Odoo 18How to Configure Canned Response & Chatbots in Odoo 18
How to Configure Canned Response & Chatbots in Odoo 18
Celine George
Ìý
How to Manage Restricted Category in Odoo 18 POS
How to Manage Restricted Category in Odoo 18 POSHow to Manage Restricted Category in Odoo 18 POS
How to Manage Restricted Category in Odoo 18 POS
Celine George
Ìý
How to Split Bills in Odoo 18 POS - Odoo 18
How to Split Bills in Odoo 18 POS - Odoo 18How to Split Bills in Odoo 18 POS - Odoo 18
How to Split Bills in Odoo 18 POS - Odoo 18
Celine George
Ìý
How to Change the Color on a Progress Bar in odoo 18
How to Change the Color on a Progress Bar in odoo 18How to Change the Color on a Progress Bar in odoo 18
How to Change the Color on a Progress Bar in odoo 18
Celine George
Ìý
How to Create Owl mixin in Odoo 17 - Odoo 17 ºÝºÝߣs
How to Create Owl mixin in Odoo 17 - Odoo 17 ºÝºÝߣsHow to Create Owl mixin in Odoo 17 - Odoo 17 ºÝºÝߣs
How to Create Owl mixin in Odoo 17 - Odoo 17 ºÝºÝߣs
Celine George
Ìý
What is Mixin Class & How to Use Mixin Classes in Odoo 18
What is Mixin Class & How to Use Mixin Classes in Odoo 18What is Mixin Class & How to Use Mixin Classes in Odoo 18
What is Mixin Class & How to Use Mixin Classes in Odoo 18
Celine George
Ìý
How to Define Menu & Actions in Odoo 18 - Odoo 18 ºÝºÝߣs
How to Define Menu & Actions in Odoo 18 - Odoo 18 ºÝºÝߣsHow to Define Menu & Actions in Odoo 18 - Odoo 18 ºÝºÝߣs
How to Define Menu & Actions in Odoo 18 - Odoo 18 ºÝºÝߣs
Celine George
Ìý
How to use search_count() method in Odoo 18
How to use search_count() method in Odoo 18How to use search_count() method in Odoo 18
How to use search_count() method in Odoo 18
Celine George
Ìý
How to Configure Flexible Working Schedule in Odoo 18 Employee
How to Configure Flexible Working Schedule in Odoo 18 EmployeeHow to Configure Flexible Working Schedule in Odoo 18 Employee
How to Configure Flexible Working Schedule in Odoo 18 Employee
Celine George
Ìý
Managing expiration dates of products in odoo
Managing expiration dates of products in odooManaging expiration dates of products in odoo
Managing expiration dates of products in odoo
Celine George
Ìý
How to Unblock Payment in Odoo 18 Accounting
How to Unblock Payment in Odoo 18 AccountingHow to Unblock Payment in Odoo 18 Accounting
How to Unblock Payment in Odoo 18 Accounting
Celine George
Ìý
How to Configure Proforma Invoice in Odoo 18 Sales
How to Configure Proforma Invoice in Odoo 18 SalesHow to Configure Proforma Invoice in Odoo 18 Sales
How to Configure Proforma Invoice in Odoo 18 Sales
Celine George
Ìý
How to Configure Deliver Content by Email in Odoo 18 Sales
How to Configure Deliver Content by Email in Odoo 18 SalesHow to Configure Deliver Content by Email in Odoo 18 Sales
How to Configure Deliver Content by Email in Odoo 18 Sales
Celine George
Ìý
Effective Product Variant Management in Odoo 18
Effective Product Variant Management in Odoo 18Effective Product Variant Management in Odoo 18
Effective Product Variant Management in Odoo 18
Celine George
Ìý
How to create security group category in Odoo 17
How to create security group category in Odoo 17How to create security group category in Odoo 17
How to create security group category in Odoo 17
Celine George
Ìý
Odoo 18 Accounting Access Rights - Odoo 18 ºÝºÝߣs
Odoo 18 Accounting Access Rights - Odoo 18 ºÝºÝߣsOdoo 18 Accounting Access Rights - Odoo 18 ºÝºÝߣs
Odoo 18 Accounting Access Rights - Odoo 18 ºÝºÝߣs
Celine George
Ìý
Inventory Reporting in Odoo 17 - Odoo 17 Inventory App
Inventory Reporting in Odoo 17 -  Odoo 17 Inventory AppInventory Reporting in Odoo 17 -  Odoo 17 Inventory App
Inventory Reporting in Odoo 17 - Odoo 17 Inventory App
Celine George
Ìý
How to Configure Recurring Revenue in Odoo 17 CRM
How to Configure Recurring Revenue in Odoo 17 CRMHow to Configure Recurring Revenue in Odoo 17 CRM
How to Configure Recurring Revenue in Odoo 17 CRM
Celine George
Ìý
One Click RFQ Cancellation in Odoo 18 - Odoo ºÝºÝߣs
One Click RFQ Cancellation in Odoo 18 - Odoo ºÝºÝߣsOne Click RFQ Cancellation in Odoo 18 - Odoo ºÝºÝߣs
One Click RFQ Cancellation in Odoo 18 - Odoo ºÝºÝߣs
Celine George
Ìý
How to Create Meetings & Channels in Odoo 18 Discuss
How to Create Meetings & Channels in Odoo 18 DiscussHow to Create Meetings & Channels in Odoo 18 Discuss
How to Create Meetings & Channels in Odoo 18 Discuss
Celine George
Ìý
How to Configure Canned Response & Chatbots in Odoo 18
How to Configure Canned Response & Chatbots in Odoo 18How to Configure Canned Response & Chatbots in Odoo 18
How to Configure Canned Response & Chatbots in Odoo 18
Celine George
Ìý
How to Manage Restricted Category in Odoo 18 POS
How to Manage Restricted Category in Odoo 18 POSHow to Manage Restricted Category in Odoo 18 POS
How to Manage Restricted Category in Odoo 18 POS
Celine George
Ìý
How to Split Bills in Odoo 18 POS - Odoo 18
How to Split Bills in Odoo 18 POS - Odoo 18How to Split Bills in Odoo 18 POS - Odoo 18
How to Split Bills in Odoo 18 POS - Odoo 18
Celine George
Ìý
How to Change the Color on a Progress Bar in odoo 18
How to Change the Color on a Progress Bar in odoo 18How to Change the Color on a Progress Bar in odoo 18
How to Change the Color on a Progress Bar in odoo 18
Celine George
Ìý
How to Create Owl mixin in Odoo 17 - Odoo 17 ºÝºÝߣs
How to Create Owl mixin in Odoo 17 - Odoo 17 ºÝºÝߣsHow to Create Owl mixin in Odoo 17 - Odoo 17 ºÝºÝߣs
How to Create Owl mixin in Odoo 17 - Odoo 17 ºÝºÝߣs
Celine George
Ìý
What is Mixin Class & How to Use Mixin Classes in Odoo 18
What is Mixin Class & How to Use Mixin Classes in Odoo 18What is Mixin Class & How to Use Mixin Classes in Odoo 18
What is Mixin Class & How to Use Mixin Classes in Odoo 18
Celine George
Ìý
How to Define Menu & Actions in Odoo 18 - Odoo 18 ºÝºÝߣs
How to Define Menu & Actions in Odoo 18 - Odoo 18 ºÝºÝߣsHow to Define Menu & Actions in Odoo 18 - Odoo 18 ºÝºÝߣs
How to Define Menu & Actions in Odoo 18 - Odoo 18 ºÝºÝߣs
Celine George
Ìý
How to use search_count() method in Odoo 18
How to use search_count() method in Odoo 18How to use search_count() method in Odoo 18
How to use search_count() method in Odoo 18
Celine George
Ìý

Recently uploaded (20)

SOCIAL CHANGE(a change in the institutional and normative structure of societ...
SOCIAL CHANGE(a change in the institutional and normative structure of societ...SOCIAL CHANGE(a change in the institutional and normative structure of societ...
SOCIAL CHANGE(a change in the institutional and normative structure of societ...
DrNidhiAgarwal
Ìý
Fuel part 1.pptx........................
Fuel part 1.pptx........................Fuel part 1.pptx........................
Fuel part 1.pptx........................
ksbhattadcm
Ìý
Storytelling instructions...............
Storytelling instructions...............Storytelling instructions...............
Storytelling instructions...............
Alexander Benito
Ìý
FESTIVAL: SINULOG & THINGYAN-LESSON 4.pptx
FESTIVAL: SINULOG & THINGYAN-LESSON 4.pptxFESTIVAL: SINULOG & THINGYAN-LESSON 4.pptx
FESTIVAL: SINULOG & THINGYAN-LESSON 4.pptx
DanmarieMuli1
Ìý
Mate, a short story by Kate Grenvile.pptx
Mate, a short story by Kate Grenvile.pptxMate, a short story by Kate Grenvile.pptx
Mate, a short story by Kate Grenvile.pptx
Liny Jenifer
Ìý
The Constitution, Government and Law making bodies .
The Constitution, Government and Law making bodies .The Constitution, Government and Law making bodies .
The Constitution, Government and Law making bodies .
saanidhyapatel09
Ìý
Blind spots in AI and Formulation Science, IFPAC 2025.pdf
Blind spots in AI and Formulation Science, IFPAC 2025.pdfBlind spots in AI and Formulation Science, IFPAC 2025.pdf
Blind spots in AI and Formulation Science, IFPAC 2025.pdf
Ajaz Hussain
Ìý
TRANSFER OF PATIENTS IN HOSPITAL SETTING.pptx
TRANSFER OF PATIENTS IN HOSPITAL SETTING.pptxTRANSFER OF PATIENTS IN HOSPITAL SETTING.pptx
TRANSFER OF PATIENTS IN HOSPITAL SETTING.pptx
PoojaSen20
Ìý
TLE 7 - 2nd Topic - Codes and Standards in Industrial Arts Services.pptx
TLE 7 - 2nd Topic - Codes and Standards in Industrial Arts Services.pptxTLE 7 - 2nd Topic - Codes and Standards in Industrial Arts Services.pptx
TLE 7 - 2nd Topic - Codes and Standards in Industrial Arts Services.pptx
RizaBedayo
Ìý
English 4 Quarter 4 Week 4 Classroom Obs
English 4 Quarter 4 Week 4 Classroom ObsEnglish 4 Quarter 4 Week 4 Classroom Obs
English 4 Quarter 4 Week 4 Classroom Obs
NerissaMendez1
Ìý
Computer Application in Business (commerce)
Computer Application in Business (commerce)Computer Application in Business (commerce)
Computer Application in Business (commerce)
Sudar Sudar
Ìý
The basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptxThe basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptx
heathfieldcps1
Ìý
Rass MELAI : an Internet MELA Quiz Finals - El Dorado 2025
Rass MELAI : an Internet MELA Quiz Finals - El Dorado 2025Rass MELAI : an Internet MELA Quiz Finals - El Dorado 2025
Rass MELAI : an Internet MELA Quiz Finals - El Dorado 2025
Conquiztadors- the Quiz Society of Sri Venkateswara College
Ìý
Eng7-Q4-Lesson 1 Part 1 Understanding Discipline-Specific Words, Voice, and T...
Eng7-Q4-Lesson 1 Part 1 Understanding Discipline-Specific Words, Voice, and T...Eng7-Q4-Lesson 1 Part 1 Understanding Discipline-Specific Words, Voice, and T...
Eng7-Q4-Lesson 1 Part 1 Understanding Discipline-Specific Words, Voice, and T...
sandynavergas1
Ìý
Research & Research Methods: Basic Concepts and Types.pptx
Research & Research Methods: Basic Concepts and Types.pptxResearch & Research Methods: Basic Concepts and Types.pptx
Research & Research Methods: Basic Concepts and Types.pptx
Dr. Sarita Anand
Ìý
The Broccoli Dog's inner voice (look A)
The Broccoli Dog's inner voice  (look A)The Broccoli Dog's inner voice  (look A)
The Broccoli Dog's inner voice (look A)
merasan
Ìý
N.C. DPI's 2023 Language Diversity Briefing
N.C. DPI's 2023 Language Diversity BriefingN.C. DPI's 2023 Language Diversity Briefing
N.C. DPI's 2023 Language Diversity Briefing
Mebane Rash
Ìý
Kaun TALHA quiz Prelims - El Dorado 2025
Kaun TALHA quiz Prelims - El Dorado 2025Kaun TALHA quiz Prelims - El Dorado 2025
Kaun TALHA quiz Prelims - El Dorado 2025
Conquiztadors- the Quiz Society of Sri Venkateswara College
Ìý
APM People Interest Network Conference - Tim Lyons - The neurological levels ...
APM People Interest Network Conference - Tim Lyons - The neurological levels ...APM People Interest Network Conference - Tim Lyons - The neurological levels ...
APM People Interest Network Conference - Tim Lyons - The neurological levels ...
Association for Project Management
Ìý
Year 10 The Senior Phase Session 3 Term 1.pptx
Year 10 The Senior Phase Session 3 Term 1.pptxYear 10 The Senior Phase Session 3 Term 1.pptx
Year 10 The Senior Phase Session 3 Term 1.pptx
mansk2
Ìý
SOCIAL CHANGE(a change in the institutional and normative structure of societ...
SOCIAL CHANGE(a change in the institutional and normative structure of societ...SOCIAL CHANGE(a change in the institutional and normative structure of societ...
SOCIAL CHANGE(a change in the institutional and normative structure of societ...
DrNidhiAgarwal
Ìý
Fuel part 1.pptx........................
Fuel part 1.pptx........................Fuel part 1.pptx........................
Fuel part 1.pptx........................
ksbhattadcm
Ìý
Storytelling instructions...............
Storytelling instructions...............Storytelling instructions...............
Storytelling instructions...............
Alexander Benito
Ìý
FESTIVAL: SINULOG & THINGYAN-LESSON 4.pptx
FESTIVAL: SINULOG & THINGYAN-LESSON 4.pptxFESTIVAL: SINULOG & THINGYAN-LESSON 4.pptx
FESTIVAL: SINULOG & THINGYAN-LESSON 4.pptx
DanmarieMuli1
Ìý
Mate, a short story by Kate Grenvile.pptx
Mate, a short story by Kate Grenvile.pptxMate, a short story by Kate Grenvile.pptx
Mate, a short story by Kate Grenvile.pptx
Liny Jenifer
Ìý
The Constitution, Government and Law making bodies .
The Constitution, Government and Law making bodies .The Constitution, Government and Law making bodies .
The Constitution, Government and Law making bodies .
saanidhyapatel09
Ìý
Blind spots in AI and Formulation Science, IFPAC 2025.pdf
Blind spots in AI and Formulation Science, IFPAC 2025.pdfBlind spots in AI and Formulation Science, IFPAC 2025.pdf
Blind spots in AI and Formulation Science, IFPAC 2025.pdf
Ajaz Hussain
Ìý
TRANSFER OF PATIENTS IN HOSPITAL SETTING.pptx
TRANSFER OF PATIENTS IN HOSPITAL SETTING.pptxTRANSFER OF PATIENTS IN HOSPITAL SETTING.pptx
TRANSFER OF PATIENTS IN HOSPITAL SETTING.pptx
PoojaSen20
Ìý
TLE 7 - 2nd Topic - Codes and Standards in Industrial Arts Services.pptx
TLE 7 - 2nd Topic - Codes and Standards in Industrial Arts Services.pptxTLE 7 - 2nd Topic - Codes and Standards in Industrial Arts Services.pptx
TLE 7 - 2nd Topic - Codes and Standards in Industrial Arts Services.pptx
RizaBedayo
Ìý
English 4 Quarter 4 Week 4 Classroom Obs
English 4 Quarter 4 Week 4 Classroom ObsEnglish 4 Quarter 4 Week 4 Classroom Obs
English 4 Quarter 4 Week 4 Classroom Obs
NerissaMendez1
Ìý
Computer Application in Business (commerce)
Computer Application in Business (commerce)Computer Application in Business (commerce)
Computer Application in Business (commerce)
Sudar Sudar
Ìý
The basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptxThe basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptx
heathfieldcps1
Ìý
Eng7-Q4-Lesson 1 Part 1 Understanding Discipline-Specific Words, Voice, and T...
Eng7-Q4-Lesson 1 Part 1 Understanding Discipline-Specific Words, Voice, and T...Eng7-Q4-Lesson 1 Part 1 Understanding Discipline-Specific Words, Voice, and T...
Eng7-Q4-Lesson 1 Part 1 Understanding Discipline-Specific Words, Voice, and T...
sandynavergas1
Ìý
Research & Research Methods: Basic Concepts and Types.pptx
Research & Research Methods: Basic Concepts and Types.pptxResearch & Research Methods: Basic Concepts and Types.pptx
Research & Research Methods: Basic Concepts and Types.pptx
Dr. Sarita Anand
Ìý
The Broccoli Dog's inner voice (look A)
The Broccoli Dog's inner voice  (look A)The Broccoli Dog's inner voice  (look A)
The Broccoli Dog's inner voice (look A)
merasan
Ìý
N.C. DPI's 2023 Language Diversity Briefing
N.C. DPI's 2023 Language Diversity BriefingN.C. DPI's 2023 Language Diversity Briefing
N.C. DPI's 2023 Language Diversity Briefing
Mebane Rash
Ìý
APM People Interest Network Conference - Tim Lyons - The neurological levels ...
APM People Interest Network Conference - Tim Lyons - The neurological levels ...APM People Interest Network Conference - Tim Lyons - The neurological levels ...
APM People Interest Network Conference - Tim Lyons - The neurological levels ...
Association for Project Management
Ìý
Year 10 The Senior Phase Session 3 Term 1.pptx
Year 10 The Senior Phase Session 3 Term 1.pptxYear 10 The Senior Phase Session 3 Term 1.pptx
Year 10 The Senior Phase Session 3 Term 1.pptx
mansk2
Ìý

How to Modify Existing Web Pages in Odoo 18

  • 1. How to Modify Existing Web Pages in Odoo 18 Enterprise
  • 2. Enterprise Introduction In this slide, we’ll discuss on how to modify existing web pages in Odoo 18. Web pages in Odoo 18 can also gather user data through user-friendly forms, encourage interaction through engaging features. However, through strategic modifications, we can transform this virtual real estate into a captivating showcase that captures visitors attention and propels them further into the sales funnel.
  • 3. Enterprise Before adding the custom code in controller, we can add custom field in product_template model. from odoo import fields, models class ProductTemplate(models.Model): _inherit = 'product.template' top_selling = fields.Boolean(string='Top selling') Next, to add this in the view, we can inherit the product_template model and add the field.
  • 4. Enterprise <?xml version="1.0" encoding="UTF-8" ?> <odoo> <record id="product_template_form_view" model="ir.ui.view"> <field name="name">product.template.inherit.view.form</field> <field name="model">product.template</field> <field name="inherit_id" ref="product.product_template_form_view"/> <field name="arch" type="xml"> <xpath expr="//field[@name='taxes_id']" position="after"> <field name="top_selling"/> </xpath> </field> </record> </odoo>
  • 5. Enterprise Next, to add top selling products of the e-commerce website on the Home Page, we can use the code snippet to fetch the top-selling products based on their sales count within a specified date range and renders them on the homepage of the website. homepage template. We can add this code in the controller of the custom module. from odoo import http from odoo.http import request from odoo.addons.website.controllers.main import Home class Website(Home): @http.route('/', auth="public", website=True, sitemap=True) def index(self, **kw): """Initialize products' sales count and top- selling flag""" products = request.env['product.template'].sudo().search([])
  • 6. Enterprise for product in products: product.sales_count = 0 product.top_selling = False orders = request.env['sale.order'].sudo().search([ ('state', 'in', ('sale', 'done'))]) for order in orders: for line in order.order_line: line.product_id.sales_count += line.product_uom_qty website_product_ids = [product for product in products if product.sales_count != 0] sorted_products = sorted(website_product_ids, key=lambda p: p.sales_count, reverse=True) # Mark the top 4 products as top-selling for product in sorted_products[3:7]: product.top_selling = True
  • 7. Enterprise # Render the homepage template with the sorted products return request.render( 'website.homepage', {'website_product_ids': sorted_products[3:7]}) To incorporate these top-selling products into the homepage, we can inherit the website. Create a homepage template and add a container within the div with the ID wrap. <?xml version="1.0" encoding="UTF-8" ?> <odoo> <template id="homepage_inherit_product_display" inherit_id="website.homepage" name="Products" active="True"> <data inherit_id="website.homepage"> <xpath expr="//div[@id='wrap']" position="inside"> <input type="hidden" name="csrf_token" t- att-value="request.csrf_token()"/>
  • 8. Enterprise <div class="container mt32 mb64"> <section> <div class="product_details"> <center> <h3>MOST SELLING PRODUCTS</h3> </center> </div> <br/> <div class="oe_product_cart_new row" style="overflow: hidden;"> <t t- foreach="website_product_ids" t-as="website_product_id"> <div class="col-md-3 col-sm-3 col-xs-12" style="padding:6px 6px 6px 6px;"> <form action="/shop/cart/update" method="post" class="card oe_product_cart" data-publish="on"> <br/> <center>
  • 9. Enterprise <div style="width:100%; height:155px;overflow: hidden;"> <a t-attf-href="/shop/product/#{ slug(website_product_id) }"> <img t-attf-src=/slideshow/how-to-modify-existing-web-pages-in-odoo-18/276332419/"/web/image model=product.template&amp;field=image_1920&amp;id=#{websit e_product_id.id}" class="img img-fluid" style="padding: 0px; margin: 0px; width:auto; height:100%;"/> </a> </div> </center> <br/> <div class="card-body p-0 text-center o_wsale_product_information"> <div class="p-2 o_wsale_product_information_text"> <h6 class="o_wsale_products_item_title">
  • 10. Enterprise <a data-oe-model="product.template" data-oe- id="website_product_id.id" data-oe-field="website_product_id.name" data-oe-type="char" data-oe- expression="product.name" itemprop="name" data-oe-field-xpath="/t[1]/form[1]/div[2]/div[1]/h6[1]/a[1] " t-attf- href="/shop/product/#{ slug(website_product_id) }" content="website_product_id.name"> <t t- esc="website_product_id.name"/> </a> </h6> <h6 class="o_wsale_products_item_title"> <span t- esc="website_product_id.currency_id.symbol" style="color:black"/> <t t-esc="website_product_id.list_price"/> </h6> </div>
  • 11. Enterprise <div class="o_wsale_product_btn" data-oe-model="ir.ui.view" data-oe-id="1561" data-oe- field="arch" data-oe- xpath="/t[1]/form[1]/div[2]/div[2]"/> </div> <span class="o_ribbon " style=""/> </form> </div> </t> </div> </section> </div> </xpath> </data> </template> </odoo>
  • 12. Enterprise This code snippet iterates over the top-selling products and displays their name, image, and price within a product cart view on the homepage.
  • 13. 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