Difference Between Search & Browse Methods in Odoo 17

925 views 6 slides Apr 19, 2024
Slide 1
Slide 1 of 6
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6

About This Presentation

In Odoo, the search and browse methods are the common ORM methods used to query and retrieve records from the database. These methods are typically used in Python code to interact with Odoo models. Both of these return a set of records based on our requirements.
Lets see how both of these methods ar...


Slide Content

Difference Between Search & Browse Methods in Odoo 17 Enterprise

Introduction Enterpr ise In Odoo, the search and browse methods are the common ORM methods used to query and retrieve records from the database. These methods are typically used in Python code to interact with Odoo models. Both of these return a set of records based on our requirements. Lets see how both of these methods are used and how they differ from each other.

Enterprise search() This method is used to search for records that match the specified domain. The domain is a list of search criteria defined using Odoo's domain syntax. It returns a list of record IDs that match the search criteria. The syntax of using search() is Model.search(domain, offset=0, limit=None, order=None, count=False)

Enterprise The attributes possible are: o ffset is used to specify the number of records to be ignored. limit is specifies the number of records to be returned order is u sed to sort the records. ASC for ascending and DESC for descending order is used. If count is set as True, it returns the number of records matching the domain. for lead in test_leads: search_res = self.env['crm.lead'].search( [('id', 'in', test_leads.ids)], limit=5, offset=0, order='id ASC') See an example for search(). Here, the search_res variable holds the first created 5 records from crm.lead model with the given domain.

Enterprise manager_id = vals.get("manager_id") manager = self.env['hr.employee'].browse(manager_id) browse() This method is used return a set of record for the IDs that are passed as arguments. The syntax of using search() is Model.browse([ids]) Eg:

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