Odoo Help


How do I display a PostgreSQL view (ie: CREATE VIEW AS...) in Odoo as a Tree view? How do I create the Python class for it?

Prihadi Ramadhany
on 9/9/16, 9:57 AM 1,464 views


I created a view from pgadmin, and now I want to display its as tree type of view.  How can I do it?

Do I need to create a class for that view?  

for example:

CREATE VIEW AS book.trans .....

on book.py

class BookTrans(models.Model):

    _name = "book.trans"

    _columns = {

   <!-- I put exacts field as view book.trans created from pgadmin ?? -->


I tried that and use field model="book.trans" on Odoo view xml code but nothing shown (not showing any error also on the screen)....any thing I missed?

Thank you community

On 9/9/16, 10:56 AM

Well, views can be updatable (see https://www.postgresql.org/docs/9.3/static/sql-createview.html)  and I suppose ORM can even work with them as with regular 'Model'.

Odoo's view objects have got a 'model' field so python class should be created.

I think you need to review class Model to ensure your view has got all columns this class requires such as, id, write_uid, create_date, maybe tree view doesn't work without them.

Do you think how to install/uninstall your module? During installation new table not a view is created.

Budi Sentosa
On 5/22/17, 2:58 AM


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.


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)


Asked: 9/9/16, 9:57 AM
Seen: 1464 times
Last updated: 5/22/17, 2:58 AM