Odoo Help


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.


how to retrrive data from database?

on 2/12/15, 12:44 AM 295 views

how to retive datafrom the table?

On 2/12/15, 5:07 AM

This is the example to retreive information from database for a table.

Here [('user_id', '=', uid)] --> Here we can include the condition we put in WHERE clause

    emp_obj = self.pool.get('hr.employee')
        emp_ids = emp_obj.search(cr, uid, [('user_id', '=', uid)], context=context)
        if emp_ids:
            for employee in emp_obj.browse(cr, uid, emp_ids, context=context):
                return {'name': employee.name}

--->Hope this helps you

Jordan Vrtanoski
On 2/12/15, 5:52 AM

It is recomandable to use object model to read data from the database, however some times it is more efficient to read data with SQL. If you want to read data with direct SQL, you can use the cr (cursor) that is passed to your methods as follows:

cr.execute(""" SELECT name FROM res_partner""")
result = cr.fetchall()
for partner in result:
   print partner[0]

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)


Asked: 2/12/15, 12:44 AM
Seen: 295 times
Last updated: 3/16/15, 8:10 AM