This question has been flagged
1 Reply
18615 Views

I have a many2one field, it display something like "model.name, 5" where 5 is the ID of my related record.

I just want to display 5 or better, another field of my related record.

Of course i found many topics speaking about this like this one ( https://www.odoo.com/forum/help-1/question/display-recordset-into-record-91284 ) but i don't understand anything :)

I am lost, in the doc and other examples, they speak of compute, name_get, related, etc.

I just want to display another field of my related record, it should be super simple.

Where can I see a very simple example of what to do for Odoo 8.

Thanks,
Sebastian

Avatar
Discard
Best Answer

Hello Sebastian,

When any field of type many2one is there inside Odoo. Odoo will take one field from that model for display. That field is by default 'name' taking from the _rec_name attribute of that class because _rec_name = 'name' is default set inside ORM class.

So, if you have not define any field with its name "name" then Odoo will give you the result as you got "Model, Id". To overcome of this you just need to define/set _rec_name inside your class. 

For ex. you have one field "xxx" which you want to display on many2one field. then you have to set _rec_name = 'xxx' thats it. Odoo will automatically display value of 'xxx' field when your many2one link is available.

Note : _rec_name = 'name' is default set. So, if you have not define 'name' field in your class/model you have to set _rec_name attribute inside your class.

It will help a lot.

Thanks. 

Avatar
Discard
Author

Thanks!