how to override name_get method in new api

can anbody tell me override name_get method in new api

In the new api, it's the field display_name. Just override the field display name to a computed one.

 class res_partner(Model):
        ...

        display_name = fields.Char(
            string='Name', compute='_compute_display_name',
        )

        @api.one
        @api.depends('name', 'parent_id.name')
        def _compute_display_name(self):
            names = [self.parent_id.name, self.name]
            self.display_name = ' / '.join(filter(None, names))

Need more info?

This documentation page has been extracted from the Q&A section where you can discuss it and get feedback.
Related question