I want know about search and search_read difference...
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Boekhouding
- Voorraad
- PoS
- Project
- MRP
Deze vraag is gerapporteerd
Hi , Here its from API guidelines..
Searching
Searching has not changed a lot. Sadly the domain changes announced did not meet release 8.0.
You will find main changes below.
search
Now seach function returns directly a RecordSet:
>>> self.search([('is_company', '=', True)])
res.partner(7, 6, 18, 12, 14, 17, 19, 8,...)
>>> self.search([('is_company', '=', True)])[0].name
'Camptocamp'
You can do a search using env:
>>> self.env['res.users'].search([('login', '=', 'admin')])
res.users(1,)
search_read
A search_read function is now available. It will do a search and return a list of dict.
Here we retrieve all partners name:
>>> self.search_read([], ['name'])
[{'id': 3, 'name': u'Administrator'},
{'id': 7, 'name': u'Agrolait'},
{'id': 43, 'name': u'Michel Fletcher'},
...]
As per the Odoo new api
search will return list of record set of the object.
i.e.
res.partner(7,)
and
search_read will return the list of dictionary containing the value of fields
i.e.
[{'id':7, 'name': 'Openies', 'desc': 'Odoo Services'}]
Geniet je van het gesprek? Blijf niet alleen lezen, doe ook mee!
Maak vandaag nog een account aan om te profiteren van exclusieve functies en deel uit te maken van onze geweldige community!
Aanmelden