Overslaan naar inhoud
Menu
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Deze vraag is gerapporteerd
2 Antwoorden
8509 Weergaven

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    

Avatar
Annuleer
Beste antwoord

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


Avatar
Annuleer

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

Beste antwoord

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

Avatar
Annuleer
Gerelateerde posts Antwoorden Weergaven Activiteit
3
okt. 20
5393
2
apr. 25
7099
2
feb. 25
5858
1
dec. 24
1420
2
jun. 24
6330