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.

0

How to create Indexes on Custom module?

By
deep
on 2/18/15, 2:02 AM 1,222 views

I  would like to know, how to create SQL indexes on the custom module using Python/ORM methods....

1

Ivan

--Ivan--
3210
| 5 3 6
Jakarta, Indonesia
--Ivan--
Ivan
On 2/18/15, 2:50 AM

If you want to create complex indexes, you need to inherit _auto_init method of the model and execute a CREATE INDEX (using cr.execute) statement after you call the super.

If you just want to create per column index - PostgreSQL is capable to combine index, just add select=1 in the column definition, like so:

'name' ; fields.char('Name', size=64, select=1)

If you are interested on how a table and it's related objects, read the _auto_init method of BaseModel.

Thanks Ivan , Yes I too found the same by referring "account_move_line" object... However I came over across 2 kinds of select parameters, i.e "select=1" means Basic Search, "select="2" means Advance Search... Any idea what exactly is the difference... In database level I see no difference between these two indexes..

deep
on 2/18/15, 4:09 AM

I think that has something to do with whether the field will be displayed as search criteria by default in a search view. If select=1, a default search view will have the field added. At least that is what I've experienced with v6. I'm not sure whether it is still valid for v7 and v8.

Ivan
on 2/19/15, 10:22 PM

Ya ok, even I feel the same.. thanks anyway :)

deep
on 2/23/15, 9:00 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: 2/18/15, 2:02 AM
Seen: 1222 times
Last updated: 10/20/16, 7:40 AM