How to change displayed value for relational field in Odoo

If you want to change the displayed value for a relational field in Odoo, the simplest way to do that is to define the “_rec_name” model’s attribute with the name of the field that you want to show.

For example, if you want to add new field “description” in the hr.employee.category model and you want that field to be shown as value for this model the code should look like:

class Employee(models.Model):
    _inherit = 'hr.employee.category'
    _rec_name = 'description'

    description = fields.Char()

Now when you try to search for a new employee tag in the hr.employee view it will search by and display the description of the hr.employee.category model.