Skip to Content
Menu
This question has been flagged
3 Replies
1939 Views

class Partner(models.Model):

    _description = 'Contact'

    _inherit = ['format.address.mixin', 'avatar.mixin']

    _name = "res.partner"

    _order = "complete_name ASC, id DESC"

    _rec_names_search = ['complete_name', 'email', 'ref', 'vat', 'company_registry']


Help me in replacing complete_name or display_name in Contacts to be name field only.

Avatar
Discard
Best Answer

Hi,
You have to inherit and modify the _compute_display_name function for this.

See:  https://www.youtube.com/watch?v=5ga7dlVoZ2M

Thanks

Avatar
Discard
Best Answer

Try inherit and overide the _rec_names_search

class ResPartner(models.Model):
​_inherit = 'res.partner'
​_rec_names_search = ['name']


Avatar
Discard
Author Best Answer
class ResPartner(models.Model):
    _inherit = 'res.partner'

    def name_get(self):
        result = []
        for partner in self:
            name = partner.name
            result.append((partner.id, name))
        return result

This code isn't helping either

Avatar
Discard

I am unsure what you exactly want.

from odoo import models, fields?, api?

class ResPartner(models.Model):
_inherit = 'res.partner'

def name_get(self):
result = super(ResPartner, self).name_get() # Call the original method to preserve existing functionality
custom_result = []
for partner in self:
name = partner.name
custom_result.append((partner.id, name))

# Combine the original result with the custom one if necessary
result.extend(custom_result)
return result

There is a basefield for "display_name", there is a basefield for "complete_name", and there is a basefield for "name".

We are trying to extract "name" from "ir.model.fields"? In the "ir.model" > "res.partner" model?

Related Posts Replies Views Activity
3
Jul 25
1458
1
Jun 25
1411
2
May 25
1413
1
May 25
746
1
May 25
1005