How to create Indexes on Custom module?

If you want to create complex indexes, PostgreSQL is capable to combine index from many columns, you need to inherit _auto_init method of the model and execute a CREATE INDEX (using cr.execute) statement after you call the super.


def _auto_init(self):
    res=super(picking, self)._auto_init()"CREATE INDEX custom_idx ON TABLE tablename (field1,field2,...)")
    return res

If you just want to create per column 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.



Videos fill be uploaded regularly, so subscribe our youtube Channel.

Visit YouTube Channel

Untuk trik Odoo lainnya bisa cek Udemy courses

Visit official site

One Touch and Go Live with Odoo


Check our blog:

How to create Indexes on Custom module?
vitraining, odoo indonesia
3 July, 2020
Share this post
Sign in to leave a comment
How to Remove "Create and Edit…" from many2one field.?