Ma7
Ma7

Reputation: 229

How to display an tree view inside notebook form view in odoo ?

I want to add a tree view inside an forme view in odoo 10,but the result is no table here is the result : enter image description here

and here is my model.py file an view.xml file :

enter image description here

enter image description here

Upvotes: 1

Views: 2094

Answers (1)

CZoellner
CZoellner

Reputation: 14801

You can only display a list view with x2many fields. A Many2one field represents exactly zero or one record. There is no widget for showing such fields in a list.

If you want to show more data like name and unit price, you can override name_get() and build up another representation of such a record like <name> (<unit_price>). You can use the context with some flags to only show this new name representation. The model res.partner is doing something like that. On normal views you can only see the partner name, but for example in orders you will also see the whole address. It's done by using the context flag show_address.

Another possibility is to write your own list widget for Many2one fields. But that would be a lot of work ;-)

Upvotes: 1

Related Questions