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

Hi.

In a relation field many2one created by studio (Many is a new model, One is Employee); by default,  the popup window shows the Employee name, I need display the Identification Number.

How can I change that behavior?

아바타
취소
베스트 답변

Hello Juan Botero Tech,
- To change the display name for the many2one field’s drop-down, either you can manage to do it using function ‘name_get’ or using _rec_name.
- You can serve this purpose just by using _rec_name.
- Or if you want to add more modifications to the display name then call the name_get function.
- Just in case if you want to display the identification number on the tree view that is visible from the search more option in the many2one field, then you can just make the field visible on the tree view of the hr employee.

Please find code in comment. 

I hope this information is helpful to you.

Thanks & Regards,
Email: odoo@aktivsoftware.com
Skype: kalpeshmaheshwari

아바타
취소

Please find the below example:

class HrEmployee(models.Model):
_inherit = "hr.employee"
_rec_name = "identification_id"

def name_get(self):
result = []
for rec in self:
result.append((rec.id, '%s' % (rec.identification_id)))
return result

작성자

Thank you Jainesh, The thing is that I choose the relation field (Many2One) with Odoo Studio, then the widget shows the name by default, to see the Identification number, the user needs to Click to 'Search more' Link.
I think that is imperative to create the new module by code.

관련 게시물 답글 화면 활동
3
2월 25
35480
2
6월 23
2871
0
8월 22
2229
2
8월 15
4921
2
3월 15
4272