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

Hello,

is there a way to show another field instead of rec name in many2one field without changing the rec name?

i mean to keep the rec_name as it is but show another field in a specific form?

Thanks    

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

To display another field in specific form only you need to add context to xml of the Many2One field Then you will override name_get method in the model of Many2one field as below 


def name_get(self):
if context is None:
    context = {}
res = []
if context.get('special_display_name', False):
    for record in self:
        res.append(record.id, rec.YOurFieldYouWantToShow)
else:
    for record in self:
        res.append(record.id, record.name)
return res


please check the below links for 

https://stackoverflow.com/questions/31724556/odoo-display-name-of-many2one-field-combination-of-2-fields


อวตาร
ละทิ้ง

XML field:
<field name="Many2oneField" context="{'special_display_name': True}"/>

คำตอบที่ดีที่สุด

Hi,

Try use use name_get method for this
For more reference check the following blog.

https://www.cybrosys.com/blog/how-to-use-of-name-get-function-in-odoo

Regards

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
Many2one field update based on condition แก้ไขแล้ว
3
ต.ค. 20
5392
2
เม.ย. 25
7096
2
ก.พ. 25
5857
1
ธ.ค. 24
1418
2
มิ.ย. 24
6330