Odoo Help

0
1 Answer
0
Subhanullah
12/8/17, 4:46 PM

Since I see your code, it is a bad prefetching to directly browse, loop through the browsed records and access their fields,  which kill the performance because ORM executes n number of queries to get this done ,  good prefetching is to browse all the records in a list first, then loop over the list, access the field and do the desired operation, which gives a good performance and avoid ORM to execute n number of queries instead use one query to get this done.

browsed_recs  = move_obj.browse(cr, uid, move_ids, context)

recs_list = [rec for rec in browse_recs]

for line in recs_list:

     if line.amount_to_pay > 0.00:

           #Do something


I hope It helps!

Ask a Question
Writer
About This Community

This platform 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.

Register
Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now