コンテンツへスキップ
メニュー
この質問にフラグが付けられました
1 返信
21528 ビュー

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

アバター
破棄
最善の回答

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. 

アバター
破棄
著作者

Thanks!

関連投稿 返信 ビュー 活動
2
2月 25
5839
1
12月 24
1405
2
12月 22
14764
1
11月 22
15922
3
8月 22
12911