๐๐๐ ๐๐๐ญ๐ก๐จ๐๐ฌ : ๐๐๐๐ซ๐๐ก()
Search Made Easy: A Guide to the search() Method
Photo by Crawford Jolly on Unsplash
The search() Method allows you to find records that match specific criteria.
It enables you to search for records in a model based on a particular domain.
Parameters:
domain: a list of tuples that define the criteria that the records must match. Use an empty list to match all records.
offset: number of results to ignore.
limit: maximum number of records to return.
order: A sort string, which specifies how the results should be sorted and returned.
Returns:
list of records that satisfy the given domain.
Raises AccessError: if user is not allowed to access requested information
Example
partners = self.env['res.partner'].search([('name', 'like', 'Mohamed')],limit=3, offset=1, order='date asc')
You can also specify multiple fields in the order string, like below:
order="name asc, date desc"
raise AccessError ?
It occurs when a user tries to perform an operation that they are not authorized to perform, such as when the user does not have the appropriate permissions for the model or record.