Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
3 ตอบกลับ
2228 มุมมอง

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.

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

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

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

Thanks

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Try inherit and overide the _rec_names_search

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


อวตาร
ละทิ้ง
ผู้เขียน คำตอบที่ดีที่สุด
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

อวตาร
ละทิ้ง

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 ตอบกลับ มุมมอง กิจกรรม
3
ก.ค. 25
2050
1
มิ.ย. 25
2421
2
พ.ค. 25
2016
1
พ.ค. 25
1226
1
พ.ค. 25
1478