How to add Domain in Many2One field in Odoo

CelineGeorge1 1,328 views 10 slides Aug 26, 2024
Slide 1
Slide 1 of 10
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
Slide 10
10

About This Presentation

This slide will show how to add domain in Many2One field in Odoo 17.Domains can be used to search for or filter data or records depending on particular criteria. A field, operator, and value are all parts of a domain. We can filter the data using a variety of operators.


Slide Content

How to add Domain in Many2One field in Odoo 17 Enterprise

Introduction Enterpr ise This slide will show how to add domain in Many2One field in Odoo 17. Domains can be used to search for or filter data or records depending on particular criteria. A field, operator, and value are all parts of a domain. We can filter the data using a variety of operators. The syntax for the domain is: domain=”[(field_name, ‘operator’, ‘value’)]”

Enterprise Let’s go to the pycharm file. Here I have created a model patient.vaccination There we need to filter the patient records from the model patient.details those who were not vaccinated.

Enterprise The domain function was added on the Many2one field patient_details_id for filtering the records those who were not vaccinated.

Enterprise Go to Hospital Management > Patient Details . There are two record created of vaccinated and not vaccinated patients.

Enterprise Let’s go to Hospital Management > Patient Vaccination and create a new record.

Enterprise There is only one record is shown, which is the patient that who vaccinated. We can also add domains on the XML views.

Enterprise Let’s go to the XML view of the model patient.vaccination. Add the domain on the field patient_details_id.

Enterprise Then run the pycharm and upgrade the module. We will get same result as we got earlier. This is the way we can add Domain in Many2One field 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