How To Return View From Python Code In Odoo 17

CelineGeorge1 729 views 9 slides Oct 11, 2024
Slide 1
Slide 1 of 9
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9

About This Presentation

This slide will show how to return view from python code in Odoo 17. Odoo provides all fields that are required for specific functionalities. But in certain specific scenarios, we need to access some views from another views so, we can return the views from python code.


Slide Content

How To Return View From Python Code In Odoo 17 Enterprise

Introduction Enterpr ise This slide will show how to return view from python code in Odoo 17. Odoo provides all fields that are required for specific functionalities. But in certain specific scenarios, we need to access some views from another views so, we can return the views from python code.

Enterprise Here, I created a custom module for hospital management and need to review the patient information of those chosen in order to create appointment.

Enterprise Let’s go to the py file of the model patient appointment. Define the function for returning the view under the button action of ‘View Patient Details’. z

Enterprise res_model - The model of the record to load. res_id - Specify the record to load (otherwise a new record will open). Here we have provided the record id, which has already been created for the patient's details. View_mode - Specify the view type that will be used to show the details. Run the pycharm and upgrade the module.

Enterprise Let’s go to Hospital Management > Appointment. Select the patient id and click on the ‘View Patient Details’ button.

Enterprise The form view of the selected patient will be shown.

Enterprise This is how we can return view from python code 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