Перейти к содержимому
Меню
Чтобы взаимодействовать с сообществом, необходимо зарегистрироваться.
Этот вопрос был отмечен
1 Ответить
2380 Представления

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.

Related Posts Ответы Просмотры Активность
3
февр. 25
35356
2
июн. 23
2811
0
авг. 22
2175
2
авг. 15
4882
2
мар. 15
4217