Skip to Content
Menu
This question has been flagged
1 Reply
9112 Views

Hi,

I am new to odoo, so just would like to know step by step method to EXECUTE QUERY AND RETRIEVE RECORDS AND DISPLAY IN XML 


Thanks

Avatar
Discard
Author

Hi Niyas ,Thanks for your Answer , but how to display those records in xml, what will be the reference

Author

Hi Niyas ,Thanks for your Answer , but how to display those records in xml, what will be the reference

How to use it in XML means ....Can you explain the process exactly ? Are you looking how to use this in template ?

Best Answer

Hi,

There is two ways to fetch  data from the database, ir, ORM method and the Queries.

To fetch the data from db using query you can do it like this,

self.env.cr.execute("SELECT id, password FROM res_users"
" WHERE password IS NOT NULL"
" AND password != ''")

The above is just a sample one.

In the ORM method, you can fecth data like this.

search -

Workorders = self.env['mrp.workorder'].search([('production_id', 'in', ids)])

browse -

currency = self.env['res.currency'].browse(self.currency_id.id)

Thanks

Avatar
Discard

Dear Niyas,

i used search and browse to fetch data but it takes 10 secs or more to display it (20 records) ,how can I fetch data faster? Do I need to used queries?

For 20 records, query and search/browse will have same speed. Also make sure that your instance is configured and optimised