Add Search Filter for Computed fields

July 19, 2024 by
admin


                                                                                                                 


In Odoo, computed fields are fields whose values are calculated based on a method rather than stored directly in the database.
There is a key limitation when it comes to using search filters with computed fields that are not stored in the database.
 If we search based on compute field without store you didn’t get a output
Solution:
Create a new model and add a compute filed

In here we specify the compute function along with the search with  parameter
Next create the compute function 

 

Also create a function that execute while  search or filter


This function receives a input value that we entered in the search bar

Add this code inside the filter record 
Searching the age values


Result


This is how to include a search filter in Odoo for computed fields.We will be writing the code to compute the value in the compute function. Also, the search function specifies what should be returned. When store=True is selected, the data is saved to the database.
By implementing a custom search method, allows for more flexible and powerful search capabilities, enabling users to find records based on complex and specific criteria that may not be possible with the default search.