Many2One fields in a tree view

Hi,

When I add a Many2One field in a tree view, I see in the filter dropdown all the fields of the model linked, so is there a simple way to add them in the tree ?
I’ve tried field=“fieldofthemany2one.field” but it doesn’t work.

Tks,
Laurent

Hi Laurent,

No, you can not add related views on tree view (nor on form view) as only fields from the current model can be shown.

Having said that, you can always create a Function field that gets the value from the related model and shows it on the current model.

You can see an example in this commit:

Note that there are more changes if you look carefully you will see that functions fields are added to sales and purchase lines.

Hope this helps!

Thanks for the quick answer, yes I use this method to add them !