콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
1 회신
21575 화면

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
5898
1
12월 24
1450
2
12월 22
14796
1
11월 22
15962
3
8월 22
12983