Hello Odooers & Developers!
Welcome to this hands-on guide! If you're building a custom module and want to display records on the website for portal users (like students, customers, or vendors), this blog is for you.
In this guide, you'll learn how to:
- Add a custom menu to the portal dashboard
- Show your records in a list view
- Open individual records in a form view
- Add a sidebar for contact information
- Secure access using portal rules
Whether you're managing student admissions, orders, tickets, or anything else, showing details in the portal gives a professional and user-friendly experience without needing backend access.
What Is the Customer Portal in Odoo?
The Customer Portal in Odoo 18 gives your customers a simple, secure way to view and manage their records, like orders, invoices, tasks, and mor,e right from your website. With Odoo 18's improved features, you can customize the portal just like backend views. Add new menus, pages, or filters to show only the information that matters to your customers. It's a great way to improve the customer experience while giving them direct access to important updates. Whether you offer odoo services, products, or support, customizing the portal helps you meet your business needs and keeps your customers informed and connected.
What You’ll Learn in This Guide:
- How to add a new menu item in the portal navigation bar
- How to create a custom controller and route for your portal page
- How to show records in a list view on the portal
- How to open individual records in a detailed form view
- How to secure access using portal user rules
To create a custom student portal menu under "Hostel Management" in Odoo 18 and show a list and form view, follow these steps step-by-step.
Step 1: Add a Custom Portal Menu (Student)
You're adding a custom "Student" menu to the portal (the page users see after logging into their portal account). This menu lets a student user view their admission details like name, date of birth, hostel info, etc.
To define the controller logic for displaying the portal menu, use the following Python code:
To add a custom menu to the website customer portal, use the following XML template:views/portal_templates.xml:
What’s happening:
- You'll inherit the portal.portal_my_home template and add a new menu item for students
- A new card titled “Student” appears on the portal dashboard.
- It displays an icon, text, and a counter showing how many admissions the logged-in user has.
- When clicked, it goes to the list view /my/student_details.
Display a “Student” menu on the portal with an icon.
Step 2: Breadcrumb Navigation (Student List + Form View)
Show breadcrumb navigation for both list and form views of student details.
What’s happening:
- When on the list view, breadcrumb shows: Student Details.
- When on the form view, breadcrumb shows:
Student Details / Admission-0001
(0001 = student's admission number)
This helps users understand their current location inside the portal.
Step 3: Student List View
To add a custom List View to the website customer portal, use the following XML template:views/portal_templates.xml:
To define the controller logic for displaying the portal List View, use the following Python code:
What’s happening:
- Student can see a list of their admissions.
- Clicking the admission number opens the form view.
- Sorting options (admission_number, state) are added too.
Show all admissions related to the logged-in user in a List view.
Before showing your form view on the Website Customer Portal, don’t forget to inherit these mixins in your model:
What’s happening:
- portal.mixin – Enables access to records from the portal and generates the portal link (access_url).
- Also define _compute_access_url to customize the portal URL shown for each record.
Step 4: Sidebar with Student Info (on Form View):
To define the controller logic for displaying the portal Form View, use the following Python code:
To add a custom Sidebar View to the website customer portal, use the following XML template:views/portal_templates.xml:
What’s happening:
- When the form is opened, the sidebar shows:
- Student image
- Name, Email, and Mobile
- Link to message
This sidebar uses the student_detail record that you passed from the controller.
What’s happening:
- You display a clean layout with the student's name, date, and state.
- You can add as many fields as needed (like room number, fees, etc.).
Display a student's full admission details in a clean, card-based format. When the form view is open, also show a sidebar with the student's image and basic information for quick reference.
Conclusion:
In summary, customizing Odoo 18 Customer Portal with a custom menu, list view, sidebar, and form view is an easy but effective method of adapting the experience for your users. It enables customers to access and maintain their records securely with ease. The list view gives a clear summary of entries, the sidebar highlights key contact and reference details, and the form view presents detailed data in a clean, structured layout. For businesses looking to enhance customer interaction and usability, this customization is essential. It was brought to you by Devintellecs, your trusted Odoo development partner.