How to add menu in Odoo 17 Website - Odoo 17 Slides
CelineGeorge1
960 views
10 slides
Aug 23, 2024
Slide 1 of 10
1
2
3
4
5
6
7
8
9
10
About This Presentation
Creating a menu in Odoo from website front end is not a big deal. From the backend, website development involves using Odoo's website builder tools and some customization.
Size: 506.64 KB
Language: en
Added: Aug 23, 2024
Slides: 10 pages
Slide Content
How to add menu in Odoo Website Enterprise
Enterprise Introduction Creating a menu in Odoo from website front end i s not a big deal. From the backend, website development involves using Odoo's website builder tools and some customization. We can check how it is done in the Odoo 17
Enterprise To create a menu in the website, let’s create a record in xml code for the model ‘website.menu’. We can give the attributes like name, parent, url, etc. The code is as follows. <?xml version="1.0" encoding="utf-8"?> <odoo> <record id="menu_booking" model="website.menu"> <field name="name">Booking</field> <field name="url">/book_travel</field> <field name="parent_id" ref="website.main_menu"/> <field name="sequence" type="int">20</field> </record> </odoo>
Enterprise Here, the properties Name is to enter the name of the menu item. Url is for entering the URL for the menu item. This can be an internal link (e.g., /about-us) or an external link. parent_id: If you want to create a submenu, select the parent menu item from the dropdown. s equence says the sequence order the menu is to be shown. Then, give the view’s file name in the manifest of the module
Enterprise This will show the menu as
Enterprise On clicking the menu, a call will be passed to the controller which contains the URL (ie here ‘/book_travel’). Either we can render a template or we can redirect to a page from the controller using controller ‘/ book_travel’ . The controller .py file is usually stored inside the directory ‘controllers’ under the main directory of the module. Here, the controller code to render the template with the details of a custom model travel.booking is in the next page.
Enterprise TravelData is the controller class of type http. Then, using the @http.route , we define the method for the earlier defined URL /book_travel . In the variable values, the needed parameters from the custom model is saved and passed while rendering the template travel_management.booking_details . from odoo import http from odoo.http import request class TravelData(http.Controller): @http.route('/book_travel', type='http', auth="public", website=True) def travel_booking_info(self, **arg): booking_detail = request.env['travel.booking'].sudo().search([]) values = {'booking': booking_detail} return request.render('travel_management.booking_details', values)
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