Odoo Help

0

Difference between using cr param and ORM in any openerp class methods?

By
Abegail Sanchez
on 10/27/14, 4:29 AM 1,108 views

Is there any speed issue when using CR and ORM specially in querying records (e.g. getting all records in table)?

using cr:

*cr.execute('SELECT * FROM Table')

using ORM:

*self.search(cr,uid,[],context=None) or

*self.pool.get('table.table').search(cr,uid,[],context=None)

1
Ludo - Neobis
On 10/27/14, 4:54 AM

Not that I know of. Sometimes queries should perform better because you directly relate to the required fields and skip the other fields.

Do note however: Relational fields and fields using "store = false" will NOT show in the database. So if you run a query on the object, those fields will be impossible to retrieve. Therefor, the ORM has a slight advantage.

HAd some cases where lenght of domain is restricted to 256 characters... so ORM has a benefit of user acces rights check, and can read functional fields; while sql approach is better and faster for more complex data select... also much faster when taking big datasets on models ( 100k + records)

Bole
on 10/28/14, 5:43 AM

Tha't I've noticed on a transactional table specially in stock move model. I had thousands of records in the table and I need to get the quantity of products per location and I just wondering why too slow to query them. In fact qty available field in product model uses the same model but I noticed it is using CR approach so it came to my mind to post this kind of doubt.

Abegail Sanchez
on 10/28/14, 9:17 PM

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

Question tools

1 follower(s)

Stats

Asked: 10/27/14, 4:29 AM
Seen: 1108 times
Last updated: 3/16/15, 8:10 AM