際際滷

際際滷Share a Scribd company logo
How to Create a Custom
Web Form View in Odoo 17
Enterprise
Introduction
Enterprise
Creating a custom web form view in Odoo 17 involves several key
steps: defining the model, creating the view, setting up actions
and menus, and defining the template and controller. Heres a
structured overview to guide you through the process:
Web Form View
Enterprise
 A Custom Web Form View in Odoo is a user interface
element that allows users to input, display, and manage
data through a web-based form.
 It is typically created by defining a model and designing a
corresponding view using XML.
 This form view is tailored to specific business needs and
can include various field types such as text fields, date
pickers, and selection boxes.
Steps
Enterprise
 Define the Model
 Create the menu
 Build the controller
 Design the template
1. Defining the Model
Enterprise
 Define the model in Odoo, they are referring to the process of
creating or specifying the structure, attributes, relationships,
and behavior of a business entity within the Odoo framework
using Python classes and associated XML files for views and
security configurations.
Code
Enterprise
2. Creating a Menu:
Enterprise
 Next, we'll add a dedicated "Booking" menu to the website.
This will make access more convenient. Users can quickly find
and use the booking feature.
Code
Enterprise
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<record id="website_partner" model="website.menu">
<field name="name">Booking</field>
<field name="url">/webform</field>
<field name="parent_id" ref="website.main_menu"/>
<field name="sequence" type="int">90</field>
</record>
</odoo>
3. Building the Controller:
Enterprise
 Develop a controller to manage HTTP requests for our
custom web form.
 This controller will have functions to display the form.
 Additionally, it will process form submissions efficiently
Code
Enterprise
from odoo.http import request, Controller, route
class WebFormController(Controller):
@route('/webform', auth='public', website=True)
def web_form(self, **kwargs):
return request.render('custom_web_form.web_form_template')
@route('/webform/submit', type='http', auth='public',
website=True, methods=['POST'])
def web_form_submit(self, **post):
request.env['custom.web.form.booking'].sudo().create({
'name': post.get('name'),
'email': post.get('email'),
})
return request.redirect('/thank-you-page')
4. Designing the Template:
Enterprise
 Design an XML template file to the structure and layout of
our web form.
 This template look exactly as form appears
Code
Enterprise
<template id="web_form_template">
<t t-call="website.layout">
<div id="wrap" class="oe_structure oe_empty">
<section class="s_website_form" data-vcss="001" data-snippet="s_website_form">
<div class="container">
<form action="/webform/submit" enctype="multipart/form-data" class="o_mark_required" data-mark="*" data-
model_name="" data-success-page="">
<input type="hidden" name="csrf_token" t-att-value="request.csrf_token()"/>
<div class="s_website_form_rows row s_col_no_bgcolor">
<div class="form-group col-12 s_website_form_field s_website_form_required" data-
type="char" data-name="Field">
<div class="row s_col_no_resize s_col_no_bgcolor">
<label class="col-form-label col-sm-auto s_website_form_label" style="width: 200px"
for="studio1">
<span class="s_website_form_label_content">Name</span>
<span class="s_website_form_mark"> *</span>
</label>
<div class="col-sm">
<input id="name" type="text" class="form-control s_website_form_input" name="name"
required="1"/>
</div></div></div>
Code Explanation
Enterprise
 This code defines a web form template using XML.
 First of all declare a template and incorporating the site's base
layout.
 Within this layout, a container div wraps the form elements,
ensuring they are displayed correctly.
Code
Enterprise
<div class="form-group col-12 s_website_form_field s_website_form_required" data-type="char" data-
name="Field">
<div class="row s_col_no_resize s_col_no_bgcolor">
<label class="col-form-label col-sm-auto s_website_form_label" style="width: 200px" for="studio1">
<span class="s_website_form_label_content">Email</span>
<span class="s_website_form_mark"> *</span></label>
<div class="col-sm">
<input id="email" type="email" class="form-control s_website_form_input" name="email"
required="1"/>
</div>
</div>
</div>
<div class="form-group col-12 s_website_form_submit" data-name="Submit Button">
<div style="width: 200px;" class="s_website_form_label"/>
<button type="submit" class="btn btn-primary">Submit</button>
</div>
Code Explanation
Enterprise
 The form itself is designed to handle user submissions and
includes a CSRF token for security.
 It features input fields for "Name" and "Email," each with labels
and required attributes, and ends with a submit button styled
with Bootstrap classes.
 The layout and structure of the form are managed through
various CSS classes and custom attributes to ensure proper
styling and functionality.
Enterprise
Conclusion
Hence this is how one can create a custom web form view in Odoo
17 .
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

Similar to How to Create a Custom Web Form View in Odoo 17 (20)

How to Create & Manage a Dashboard Using OWL in Odoo 17
How to Create & Manage a Dashboard Using OWL in Odoo 17How to Create & Manage a Dashboard Using OWL in Odoo 17
How to Create & Manage a Dashboard Using OWL in Odoo 17
Celine George
Introduction to Django
Introduction to DjangoIntroduction to Django
Introduction to Django
Joaquim Rocha
How to add Many2Many fields in odoo website form.pptx
How to add Many2Many fields in odoo website form.pptxHow to add Many2Many fields in odoo website form.pptx
How to add Many2Many fields in odoo website form.pptx
Celine George
How to Create Cohort View in Odoo 17 - Odoo 17 際際滷s
How to Create Cohort View in Odoo 17 - Odoo 17 際際滷sHow to Create Cohort View in Odoo 17 - Odoo 17 際際滷s
How to Create Cohort View in Odoo 17 - Odoo 17 際際滷s
Celine George
SenchaCon 2016: Handle Real-World Data with Confidence - Fredric Berling
SenchaCon 2016: Handle Real-World Data with Confidence - Fredric Berling SenchaCon 2016: Handle Real-World Data with Confidence - Fredric Berling
SenchaCon 2016: Handle Real-World Data with Confidence - Fredric Berling
Sencha
User Profiles: I Didn't Know I Could Do That (Updated Demo)
User Profiles:  I Didn't Know I Could Do That (Updated Demo)User Profiles:  I Didn't Know I Could Do That (Updated Demo)
User Profiles: I Didn't Know I Could Do That (Updated Demo)
Stacy Deere
How To Extend Odoo Form View using js_class_
How To Extend Odoo Form View using js_class_How To Extend Odoo Form View using js_class_
How To Extend Odoo Form View using js_class_
Celine George
mean stack
mean stackmean stack
mean stack
michaelaaron25322
Develop an App with the Odoo Framework
Develop an App with the Odoo FrameworkDevelop an App with the Odoo Framework
Develop an App with the Odoo Framework
Odoo
How to Store Data on the Odoo 17 Website
How to Store Data on the Odoo 17 WebsiteHow to Store Data on the Odoo 17 Website
How to Store Data on the Odoo 17 Website
Celine George
ASP.NET Core MVC with EF Core code first
ASP.NET Core MVC with EF Core code firstASP.NET Core MVC with EF Core code first
ASP.NET Core MVC with EF Core code first
Md. Aftab Uddin Kajal
Web components - An Introduction
Web components - An IntroductionWeb components - An Introduction
Web components - An Introduction
cherukumilli2
How to Create a Custom Screen in Odoo 17 POS
How to Create a Custom Screen in Odoo 17 POSHow to Create a Custom Screen in Odoo 17 POS
How to Create a Custom Screen in Odoo 17 POS
Celine George
Dexterity in the Wild
Dexterity in the WildDexterity in the Wild
Dexterity in the Wild
David Glick
AngularJs Workshop SDP December 28th 2014
AngularJs Workshop SDP December 28th 2014AngularJs Workshop SDP December 28th 2014
AngularJs Workshop SDP December 28th 2014
Ran Wahle
Angularjs Live Project
Angularjs Live ProjectAngularjs Live Project
Angularjs Live Project
Mohd Manzoor Ahmed
Xml operations in odoo
Xml operations in odooXml operations in odoo
Xml operations in odoo
Celine George
BITM3730Week11.pptx
BITM3730Week11.pptxBITM3730Week11.pptx
BITM3730Week11.pptx
MattMarino13
Why Django for Web Development
Why Django for Web DevelopmentWhy Django for Web Development
Why Django for Web Development
Morteza Zohoori Shoar
Webform and Drupal 8
Webform and Drupal 8Webform and Drupal 8
Webform and Drupal 8
Philip Norton
How to Create & Manage a Dashboard Using OWL in Odoo 17
How to Create & Manage a Dashboard Using OWL in Odoo 17How to Create & Manage a Dashboard Using OWL in Odoo 17
How to Create & Manage a Dashboard Using OWL in Odoo 17
Celine George
Introduction to Django
Introduction to DjangoIntroduction to Django
Introduction to Django
Joaquim Rocha
How to add Many2Many fields in odoo website form.pptx
How to add Many2Many fields in odoo website form.pptxHow to add Many2Many fields in odoo website form.pptx
How to add Many2Many fields in odoo website form.pptx
Celine George
How to Create Cohort View in Odoo 17 - Odoo 17 際際滷s
How to Create Cohort View in Odoo 17 - Odoo 17 際際滷sHow to Create Cohort View in Odoo 17 - Odoo 17 際際滷s
How to Create Cohort View in Odoo 17 - Odoo 17 際際滷s
Celine George
SenchaCon 2016: Handle Real-World Data with Confidence - Fredric Berling
SenchaCon 2016: Handle Real-World Data with Confidence - Fredric Berling SenchaCon 2016: Handle Real-World Data with Confidence - Fredric Berling
SenchaCon 2016: Handle Real-World Data with Confidence - Fredric Berling
Sencha
User Profiles: I Didn't Know I Could Do That (Updated Demo)
User Profiles:  I Didn't Know I Could Do That (Updated Demo)User Profiles:  I Didn't Know I Could Do That (Updated Demo)
User Profiles: I Didn't Know I Could Do That (Updated Demo)
Stacy Deere
How To Extend Odoo Form View using js_class_
How To Extend Odoo Form View using js_class_How To Extend Odoo Form View using js_class_
How To Extend Odoo Form View using js_class_
Celine George
Develop an App with the Odoo Framework
Develop an App with the Odoo FrameworkDevelop an App with the Odoo Framework
Develop an App with the Odoo Framework
Odoo
How to Store Data on the Odoo 17 Website
How to Store Data on the Odoo 17 WebsiteHow to Store Data on the Odoo 17 Website
How to Store Data on the Odoo 17 Website
Celine George
ASP.NET Core MVC with EF Core code first
ASP.NET Core MVC with EF Core code firstASP.NET Core MVC with EF Core code first
ASP.NET Core MVC with EF Core code first
Md. Aftab Uddin Kajal
Web components - An Introduction
Web components - An IntroductionWeb components - An Introduction
Web components - An Introduction
cherukumilli2
How to Create a Custom Screen in Odoo 17 POS
How to Create a Custom Screen in Odoo 17 POSHow to Create a Custom Screen in Odoo 17 POS
How to Create a Custom Screen in Odoo 17 POS
Celine George
Dexterity in the Wild
Dexterity in the WildDexterity in the Wild
Dexterity in the Wild
David Glick
AngularJs Workshop SDP December 28th 2014
AngularJs Workshop SDP December 28th 2014AngularJs Workshop SDP December 28th 2014
AngularJs Workshop SDP December 28th 2014
Ran Wahle
Xml operations in odoo
Xml operations in odooXml operations in odoo
Xml operations in odoo
Celine George
BITM3730Week11.pptx
BITM3730Week11.pptxBITM3730Week11.pptx
BITM3730Week11.pptx
MattMarino13
Webform and Drupal 8
Webform and Drupal 8Webform and Drupal 8
Webform and Drupal 8
Philip Norton

More from Celine George (20)

Analysis of Conf File Parameters in the Odoo 18
Analysis of Conf File Parameters in the Odoo 18Analysis of Conf File Parameters in the Odoo 18
Analysis of Conf File Parameters in the Odoo 18
Celine George
Purchase Analysis in Odoo 17 - Odoo 際際滷s
Purchase Analysis in Odoo 17 - Odoo 際際滷sPurchase Analysis in Odoo 17 - Odoo 際際滷s
Purchase Analysis in Odoo 17 - Odoo 際際滷s
Celine George
Analysis of Conf File Parameters in Odoo 17
Analysis of Conf File Parameters in Odoo 17Analysis of Conf File Parameters in Odoo 17
Analysis of Conf File Parameters in Odoo 17
Celine George
How to Manage Check Out Process in Odoo 17 Website
How to Manage Check Out Process in Odoo 17 WebsiteHow to Manage Check Out Process in Odoo 17 Website
How to Manage Check Out Process in Odoo 17 Website
Celine George
Managing Online Signature and Payment with Odoo 17
Managing Online Signature and Payment with Odoo 17Managing Online Signature and Payment with Odoo 17
Managing Online Signature and Payment with Odoo 17
Celine George
Recruitment in the Odoo 17 - Odoo 17 際際滷s
Recruitment in the Odoo 17 - Odoo 17 際際滷sRecruitment in the Odoo 17 - Odoo 17 際際滷s
Recruitment in the Odoo 17 - Odoo 17 際際滷s
Celine George
How to Setup Company Data in Odoo 17 Accounting App
How to Setup Company Data in Odoo 17 Accounting AppHow to Setup Company Data in Odoo 17 Accounting App
How to Setup Company Data in Odoo 17 Accounting App
Celine George
How to Install Odoo 18 with Pycharm - Odoo 18 際際滷s
How to Install Odoo 18 with Pycharm - Odoo 18 際際滷sHow to Install Odoo 18 with Pycharm - Odoo 18 際際滷s
How to Install Odoo 18 with Pycharm - Odoo 18 際際滷s
Celine George
How to Manage Purchase Order Approval in Odoo 18
How to Manage Purchase Order Approval in Odoo 18How to Manage Purchase Order Approval in Odoo 18
How to Manage Purchase Order Approval in Odoo 18
Celine George
How to Configure Outgoing and Incoming mail servers in Odoo 18
How to Configure Outgoing and Incoming mail servers in Odoo 18How to Configure Outgoing and Incoming mail servers in Odoo 18
How to Configure Outgoing and Incoming mail servers in Odoo 18
Celine George
How to Grant Discounts in Sale Order Lines in Odoo 18 Sales
How to Grant Discounts in Sale Order Lines in Odoo 18 SalesHow to Grant Discounts in Sale Order Lines in Odoo 18 Sales
How to Grant Discounts in Sale Order Lines in Odoo 18 Sales
Celine George
Comparing RFQ Lines for the best price in Odoo 17
Comparing RFQ Lines for the best price in Odoo 17Comparing RFQ Lines for the best price in Odoo 17
Comparing RFQ Lines for the best price in Odoo 17
Celine George
List View Attributes in Odoo 18 - Odoo 際際滷s
List View Attributes in Odoo 18 - Odoo 際際滷sList View Attributes in Odoo 18 - Odoo 際際滷s
List View Attributes in Odoo 18 - Odoo 際際滷s
Celine George
How to Set Default Terms and Conditions in Odoo 17 Accounting
How to Set Default Terms and Conditions in Odoo 17 AccountingHow to Set Default Terms and Conditions in Odoo 17 Accounting
How to Set Default Terms and Conditions in Odoo 17 Accounting
Celine George
Enhance Your Quotations by Sections, Notes, and Subtotals in Odoo Sales
Enhance Your Quotations by Sections, Notes, and Subtotals in Odoo SalesEnhance Your Quotations by Sections, Notes, and Subtotals in Odoo Sales
Enhance Your Quotations by Sections, Notes, and Subtotals in Odoo Sales
Celine George
What are the Views in Odoo 18 Purchase - Odoo 際際滷s
What are the Views in Odoo 18 Purchase - Odoo 際際滷sWhat are the Views in Odoo 18 Purchase - Odoo 際際滷s
What are the Views in Odoo 18 Purchase - Odoo 際際滷s
Celine George
Configuration of Python and SQL Constraints in Odoo 18
Configuration of Python and SQL Constraints in Odoo 18Configuration of Python and SQL Constraints in Odoo 18
Configuration of Python and SQL Constraints in Odoo 18
Celine George
How to Add Custom Fields to Configuration Settings in Odoo 18
How to Add Custom Fields to  Configuration Settings in Odoo 18How to Add Custom Fields to  Configuration Settings in Odoo 18
How to Add Custom Fields to Configuration Settings in Odoo 18
Celine George
How to Manage Abandoned Cart in Odoo 17 Website
How to Manage Abandoned Cart in Odoo 17 WebsiteHow to Manage Abandoned Cart in Odoo 17 Website
How to Manage Abandoned Cart in Odoo 17 Website
Celine George
How to Add opening Balance in Odoo Accounting
How to Add opening Balance in Odoo AccountingHow to Add opening Balance in Odoo Accounting
How to Add opening Balance in Odoo Accounting
Celine George
Analysis of Conf File Parameters in the Odoo 18
Analysis of Conf File Parameters in the Odoo 18Analysis of Conf File Parameters in the Odoo 18
Analysis of Conf File Parameters in the Odoo 18
Celine George
Purchase Analysis in Odoo 17 - Odoo 際際滷s
Purchase Analysis in Odoo 17 - Odoo 際際滷sPurchase Analysis in Odoo 17 - Odoo 際際滷s
Purchase Analysis in Odoo 17 - Odoo 際際滷s
Celine George
Analysis of Conf File Parameters in Odoo 17
Analysis of Conf File Parameters in Odoo 17Analysis of Conf File Parameters in Odoo 17
Analysis of Conf File Parameters in Odoo 17
Celine George
How to Manage Check Out Process in Odoo 17 Website
How to Manage Check Out Process in Odoo 17 WebsiteHow to Manage Check Out Process in Odoo 17 Website
How to Manage Check Out Process in Odoo 17 Website
Celine George
Managing Online Signature and Payment with Odoo 17
Managing Online Signature and Payment with Odoo 17Managing Online Signature and Payment with Odoo 17
Managing Online Signature and Payment with Odoo 17
Celine George
Recruitment in the Odoo 17 - Odoo 17 際際滷s
Recruitment in the Odoo 17 - Odoo 17 際際滷sRecruitment in the Odoo 17 - Odoo 17 際際滷s
Recruitment in the Odoo 17 - Odoo 17 際際滷s
Celine George
How to Setup Company Data in Odoo 17 Accounting App
How to Setup Company Data in Odoo 17 Accounting AppHow to Setup Company Data in Odoo 17 Accounting App
How to Setup Company Data in Odoo 17 Accounting App
Celine George
How to Install Odoo 18 with Pycharm - Odoo 18 際際滷s
How to Install Odoo 18 with Pycharm - Odoo 18 際際滷sHow to Install Odoo 18 with Pycharm - Odoo 18 際際滷s
How to Install Odoo 18 with Pycharm - Odoo 18 際際滷s
Celine George
How to Manage Purchase Order Approval in Odoo 18
How to Manage Purchase Order Approval in Odoo 18How to Manage Purchase Order Approval in Odoo 18
How to Manage Purchase Order Approval in Odoo 18
Celine George
How to Configure Outgoing and Incoming mail servers in Odoo 18
How to Configure Outgoing and Incoming mail servers in Odoo 18How to Configure Outgoing and Incoming mail servers in Odoo 18
How to Configure Outgoing and Incoming mail servers in Odoo 18
Celine George
How to Grant Discounts in Sale Order Lines in Odoo 18 Sales
How to Grant Discounts in Sale Order Lines in Odoo 18 SalesHow to Grant Discounts in Sale Order Lines in Odoo 18 Sales
How to Grant Discounts in Sale Order Lines in Odoo 18 Sales
Celine George
Comparing RFQ Lines for the best price in Odoo 17
Comparing RFQ Lines for the best price in Odoo 17Comparing RFQ Lines for the best price in Odoo 17
Comparing RFQ Lines for the best price in Odoo 17
Celine George
List View Attributes in Odoo 18 - Odoo 際際滷s
List View Attributes in Odoo 18 - Odoo 際際滷sList View Attributes in Odoo 18 - Odoo 際際滷s
List View Attributes in Odoo 18 - Odoo 際際滷s
Celine George
How to Set Default Terms and Conditions in Odoo 17 Accounting
How to Set Default Terms and Conditions in Odoo 17 AccountingHow to Set Default Terms and Conditions in Odoo 17 Accounting
How to Set Default Terms and Conditions in Odoo 17 Accounting
Celine George
Enhance Your Quotations by Sections, Notes, and Subtotals in Odoo Sales
Enhance Your Quotations by Sections, Notes, and Subtotals in Odoo SalesEnhance Your Quotations by Sections, Notes, and Subtotals in Odoo Sales
Enhance Your Quotations by Sections, Notes, and Subtotals in Odoo Sales
Celine George
What are the Views in Odoo 18 Purchase - Odoo 際際滷s
What are the Views in Odoo 18 Purchase - Odoo 際際滷sWhat are the Views in Odoo 18 Purchase - Odoo 際際滷s
What are the Views in Odoo 18 Purchase - Odoo 際際滷s
Celine George
Configuration of Python and SQL Constraints in Odoo 18
Configuration of Python and SQL Constraints in Odoo 18Configuration of Python and SQL Constraints in Odoo 18
Configuration of Python and SQL Constraints in Odoo 18
Celine George
How to Add Custom Fields to Configuration Settings in Odoo 18
How to Add Custom Fields to  Configuration Settings in Odoo 18How to Add Custom Fields to  Configuration Settings in Odoo 18
How to Add Custom Fields to Configuration Settings in Odoo 18
Celine George
How to Manage Abandoned Cart in Odoo 17 Website
How to Manage Abandoned Cart in Odoo 17 WebsiteHow to Manage Abandoned Cart in Odoo 17 Website
How to Manage Abandoned Cart in Odoo 17 Website
Celine George
How to Add opening Balance in Odoo Accounting
How to Add opening Balance in Odoo AccountingHow to Add opening Balance in Odoo Accounting
How to Add opening Balance in Odoo Accounting
Celine George

Recently uploaded (20)

MIPLM subject matter expert Nicos Raftis
MIPLM subject matter expert Nicos RaftisMIPLM subject matter expert Nicos Raftis
MIPLM subject matter expert Nicos Raftis
MIPLM
Quizzitch Cup_Sports Quiz 2025_Prelims.pptx
Quizzitch Cup_Sports Quiz 2025_Prelims.pptxQuizzitch Cup_Sports Quiz 2025_Prelims.pptx
Quizzitch Cup_Sports Quiz 2025_Prelims.pptx
Anand Kumar
Different Facets of Knowledge on different View.pptx
Different Facets of Knowledge on different View.pptxDifferent Facets of Knowledge on different View.pptx
Different Facets of Knowledge on different View.pptx
NrapendraVirSingh
NURSING PROCESS AND ITS STEPS .pptx
NURSING PROCESS AND ITS STEPS                 .pptxNURSING PROCESS AND ITS STEPS                 .pptx
NURSING PROCESS AND ITS STEPS .pptx
PoojaSen20
Week 6 - EDL 290F - No Drop Ride (2025).pdf
Week 6 - EDL 290F - No Drop Ride (2025).pdfWeek 6 - EDL 290F - No Drop Ride (2025).pdf
Week 6 - EDL 290F - No Drop Ride (2025).pdf
Liz Walsh-Trevino
MIPLM subject matter expert Sascha Kamhuber
MIPLM subject matter expert Sascha KamhuberMIPLM subject matter expert Sascha Kamhuber
MIPLM subject matter expert Sascha Kamhuber
MIPLM
Different perspectives on dugout canoe heritage of Soomaa.pdf
Different perspectives on dugout canoe heritage of Soomaa.pdfDifferent perspectives on dugout canoe heritage of Soomaa.pdf
Different perspectives on dugout canoe heritage of Soomaa.pdf
Aivar Ruukel
U.S. Department of Education certification
U.S. Department of Education certificationU.S. Department of Education certification
U.S. Department of Education certification
Mebane Rash
Unit 3: Combustion in Spark Ignition Engines
Unit 3: Combustion in Spark Ignition EnginesUnit 3: Combustion in Spark Ignition Engines
Unit 3: Combustion in Spark Ignition Engines
NileshKumbhar21
Design approaches and ethical challenges in Artificial Intelligence tools for...
Design approaches and ethical challenges in Artificial Intelligence tools for...Design approaches and ethical challenges in Artificial Intelligence tools for...
Design approaches and ethical challenges in Artificial Intelligence tools for...
Yannis
Berry_Kanisha_BAS_PB1_202503 (2) (2).pdf
Berry_Kanisha_BAS_PB1_202503 (2) (2).pdfBerry_Kanisha_BAS_PB1_202503 (2) (2).pdf
Berry_Kanisha_BAS_PB1_202503 (2) (2).pdf
KanishaBerry
Knownsense 2025 Finals-U-25 General Quiz.pdf
Knownsense 2025 Finals-U-25 General Quiz.pdfKnownsense 2025 Finals-U-25 General Quiz.pdf
Knownsense 2025 Finals-U-25 General Quiz.pdf
Pragya - UEM Kolkata Quiz Club
Pass SAP C_C4H47_2503 in 2025 | Latest Exam Questions & Study Material
Pass SAP C_C4H47_2503 in 2025 | Latest Exam Questions & Study MaterialPass SAP C_C4H47_2503 in 2025 | Latest Exam Questions & Study Material
Pass SAP C_C4H47_2503 in 2025 | Latest Exam Questions & Study Material
Jenny408767
compiler design BCS613C question bank 2022 scheme
compiler design BCS613C question bank 2022 schemecompiler design BCS613C question bank 2022 scheme
compiler design BCS613C question bank 2022 scheme
Suvarna Hiremath
Studying and Notetaking: Some Suggestions
Studying and Notetaking: Some SuggestionsStudying and Notetaking: Some Suggestions
Studying and Notetaking: Some Suggestions
Damian T. Gordon
Introduction to Systematic Reviews - Prof Ejaz Khan
Introduction to Systematic Reviews - Prof Ejaz KhanIntroduction to Systematic Reviews - Prof Ejaz Khan
Introduction to Systematic Reviews - Prof Ejaz Khan
Systematic Reviews Network (SRN)
20250402 ACCA TeamScienceAIEra 20250402 v10.pptx
20250402 ACCA TeamScienceAIEra 20250402 v10.pptx20250402 ACCA TeamScienceAIEra 20250402 v10.pptx
20250402 ACCA TeamScienceAIEra 20250402 v10.pptx
home
The basics of sentences session 10pptx.pptx
The basics of sentences session 10pptx.pptxThe basics of sentences session 10pptx.pptx
The basics of sentences session 10pptx.pptx
heathfieldcps1
3. AI Trust Layer, Governance Explainability, Security & Compliance.pdf
3. AI Trust Layer, Governance  Explainability, Security & Compliance.pdf3. AI Trust Layer, Governance  Explainability, Security & Compliance.pdf
3. AI Trust Layer, Governance Explainability, Security & Compliance.pdf
Mukesh Kala
MIPLM subject matter expert Nicos Raftis
MIPLM subject matter expert Nicos RaftisMIPLM subject matter expert Nicos Raftis
MIPLM subject matter expert Nicos Raftis
MIPLM
Quizzitch Cup_Sports Quiz 2025_Prelims.pptx
Quizzitch Cup_Sports Quiz 2025_Prelims.pptxQuizzitch Cup_Sports Quiz 2025_Prelims.pptx
Quizzitch Cup_Sports Quiz 2025_Prelims.pptx
Anand Kumar
Different Facets of Knowledge on different View.pptx
Different Facets of Knowledge on different View.pptxDifferent Facets of Knowledge on different View.pptx
Different Facets of Knowledge on different View.pptx
NrapendraVirSingh
NURSING PROCESS AND ITS STEPS .pptx
NURSING PROCESS AND ITS STEPS                 .pptxNURSING PROCESS AND ITS STEPS                 .pptx
NURSING PROCESS AND ITS STEPS .pptx
PoojaSen20
Week 6 - EDL 290F - No Drop Ride (2025).pdf
Week 6 - EDL 290F - No Drop Ride (2025).pdfWeek 6 - EDL 290F - No Drop Ride (2025).pdf
Week 6 - EDL 290F - No Drop Ride (2025).pdf
Liz Walsh-Trevino
MIPLM subject matter expert Sascha Kamhuber
MIPLM subject matter expert Sascha KamhuberMIPLM subject matter expert Sascha Kamhuber
MIPLM subject matter expert Sascha Kamhuber
MIPLM
Different perspectives on dugout canoe heritage of Soomaa.pdf
Different perspectives on dugout canoe heritage of Soomaa.pdfDifferent perspectives on dugout canoe heritage of Soomaa.pdf
Different perspectives on dugout canoe heritage of Soomaa.pdf
Aivar Ruukel
U.S. Department of Education certification
U.S. Department of Education certificationU.S. Department of Education certification
U.S. Department of Education certification
Mebane Rash
Unit 3: Combustion in Spark Ignition Engines
Unit 3: Combustion in Spark Ignition EnginesUnit 3: Combustion in Spark Ignition Engines
Unit 3: Combustion in Spark Ignition Engines
NileshKumbhar21
Design approaches and ethical challenges in Artificial Intelligence tools for...
Design approaches and ethical challenges in Artificial Intelligence tools for...Design approaches and ethical challenges in Artificial Intelligence tools for...
Design approaches and ethical challenges in Artificial Intelligence tools for...
Yannis
Berry_Kanisha_BAS_PB1_202503 (2) (2).pdf
Berry_Kanisha_BAS_PB1_202503 (2) (2).pdfBerry_Kanisha_BAS_PB1_202503 (2) (2).pdf
Berry_Kanisha_BAS_PB1_202503 (2) (2).pdf
KanishaBerry
Pass SAP C_C4H47_2503 in 2025 | Latest Exam Questions & Study Material
Pass SAP C_C4H47_2503 in 2025 | Latest Exam Questions & Study MaterialPass SAP C_C4H47_2503 in 2025 | Latest Exam Questions & Study Material
Pass SAP C_C4H47_2503 in 2025 | Latest Exam Questions & Study Material
Jenny408767
compiler design BCS613C question bank 2022 scheme
compiler design BCS613C question bank 2022 schemecompiler design BCS613C question bank 2022 scheme
compiler design BCS613C question bank 2022 scheme
Suvarna Hiremath
Studying and Notetaking: Some Suggestions
Studying and Notetaking: Some SuggestionsStudying and Notetaking: Some Suggestions
Studying and Notetaking: Some Suggestions
Damian T. Gordon
20250402 ACCA TeamScienceAIEra 20250402 v10.pptx
20250402 ACCA TeamScienceAIEra 20250402 v10.pptx20250402 ACCA TeamScienceAIEra 20250402 v10.pptx
20250402 ACCA TeamScienceAIEra 20250402 v10.pptx
home
The basics of sentences session 10pptx.pptx
The basics of sentences session 10pptx.pptxThe basics of sentences session 10pptx.pptx
The basics of sentences session 10pptx.pptx
heathfieldcps1
3. AI Trust Layer, Governance Explainability, Security & Compliance.pdf
3. AI Trust Layer, Governance  Explainability, Security & Compliance.pdf3. AI Trust Layer, Governance  Explainability, Security & Compliance.pdf
3. AI Trust Layer, Governance Explainability, Security & Compliance.pdf
Mukesh Kala

How to Create a Custom Web Form View in Odoo 17

  • 1. How to Create a Custom Web Form View in Odoo 17 Enterprise
  • 2. Introduction Enterprise Creating a custom web form view in Odoo 17 involves several key steps: defining the model, creating the view, setting up actions and menus, and defining the template and controller. Heres a structured overview to guide you through the process:
  • 3. Web Form View Enterprise A Custom Web Form View in Odoo is a user interface element that allows users to input, display, and manage data through a web-based form. It is typically created by defining a model and designing a corresponding view using XML. This form view is tailored to specific business needs and can include various field types such as text fields, date pickers, and selection boxes.
  • 4. Steps Enterprise Define the Model Create the menu Build the controller Design the template
  • 5. 1. Defining the Model Enterprise Define the model in Odoo, they are referring to the process of creating or specifying the structure, attributes, relationships, and behavior of a business entity within the Odoo framework using Python classes and associated XML files for views and security configurations.
  • 7. 2. Creating a Menu: Enterprise Next, we'll add a dedicated "Booking" menu to the website. This will make access more convenient. Users can quickly find and use the booking feature.
  • 8. Code Enterprise <?xml version="1.0" encoding="UTF-8" ?> <odoo> <record id="website_partner" model="website.menu"> <field name="name">Booking</field> <field name="url">/webform</field> <field name="parent_id" ref="website.main_menu"/> <field name="sequence" type="int">90</field> </record> </odoo>
  • 9. 3. Building the Controller: Enterprise Develop a controller to manage HTTP requests for our custom web form. This controller will have functions to display the form. Additionally, it will process form submissions efficiently
  • 10. Code Enterprise from odoo.http import request, Controller, route class WebFormController(Controller): @route('/webform', auth='public', website=True) def web_form(self, **kwargs): return request.render('custom_web_form.web_form_template') @route('/webform/submit', type='http', auth='public', website=True, methods=['POST']) def web_form_submit(self, **post): request.env['custom.web.form.booking'].sudo().create({ 'name': post.get('name'), 'email': post.get('email'), }) return request.redirect('/thank-you-page')
  • 11. 4. Designing the Template: Enterprise Design an XML template file to the structure and layout of our web form. This template look exactly as form appears
  • 12. Code Enterprise <template id="web_form_template"> <t t-call="website.layout"> <div id="wrap" class="oe_structure oe_empty"> <section class="s_website_form" data-vcss="001" data-snippet="s_website_form"> <div class="container"> <form action="/webform/submit" enctype="multipart/form-data" class="o_mark_required" data-mark="*" data- model_name="" data-success-page=""> <input type="hidden" name="csrf_token" t-att-value="request.csrf_token()"/> <div class="s_website_form_rows row s_col_no_bgcolor"> <div class="form-group col-12 s_website_form_field s_website_form_required" data- type="char" data-name="Field"> <div class="row s_col_no_resize s_col_no_bgcolor"> <label class="col-form-label col-sm-auto s_website_form_label" style="width: 200px" for="studio1"> <span class="s_website_form_label_content">Name</span> <span class="s_website_form_mark"> *</span> </label> <div class="col-sm"> <input id="name" type="text" class="form-control s_website_form_input" name="name" required="1"/> </div></div></div>
  • 13. Code Explanation Enterprise This code defines a web form template using XML. First of all declare a template and incorporating the site's base layout. Within this layout, a container div wraps the form elements, ensuring they are displayed correctly.
  • 14. Code Enterprise <div class="form-group col-12 s_website_form_field s_website_form_required" data-type="char" data- name="Field"> <div class="row s_col_no_resize s_col_no_bgcolor"> <label class="col-form-label col-sm-auto s_website_form_label" style="width: 200px" for="studio1"> <span class="s_website_form_label_content">Email</span> <span class="s_website_form_mark"> *</span></label> <div class="col-sm"> <input id="email" type="email" class="form-control s_website_form_input" name="email" required="1"/> </div> </div> </div> <div class="form-group col-12 s_website_form_submit" data-name="Submit Button"> <div style="width: 200px;" class="s_website_form_label"/> <button type="submit" class="btn btn-primary">Submit</button> </div>
  • 15. Code Explanation Enterprise The form itself is designed to handle user submissions and includes a CSRF token for security. It features input fields for "Name" and "Email," each with labels and required attributes, and ends with a submit button styled with Bootstrap classes. The layout and structure of the form are managed through various CSS classes and custom attributes to ensure proper styling and functionality.
  • 16. Enterprise Conclusion Hence this is how one can create a custom web form view in Odoo 17 .
  • 17. 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