Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

2

Difference between search and search_read in odoo 8?

By
Bailey
on 3/30/15, 9:52 AM 3,845 views

I want know about search and search_read difference...

1

Baiju

--Baiju--
3154
| 5 4 8
Kochi, India
--Baiju--
ODOO technical and functional

        I like learning new thing, especially technical thing. I am a quick learner, I can learn technical things very fast. I have good logical skill,  I have immense interest in programming.

e-mail id : baijuks@hotmail.com

Baiju
On 3/31/15, 1:50 AM

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'},

...]

3

Openies Services

--Openies Services--
925
| 2 2 4
Vadodara, India
--Openies Services--

We provide Odoo Services.

Contact us on : contact@openies.com

Openies Services
On 3/31/15, 2:11 AM

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'}]

0

zbik

--zbik--
5941
| 6 4 7
Lodz, Poland
--zbik--


zbik
On 3/30/15, 10:16 AM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 3/30/15, 9:52 AM
Seen: 3845 times
Last updated: 8/5/15, 3:01 AM