コンテンツへスキップ
メニュー
この質問にフラグが付けられました
5647 ビュー

Hi, 

I'm trying to change the ouput of items in a Many2one field. By items

I mean the displayed values in the generated select box.


My field

company_contact_id = fields.Many2one('res.partner', string='Company contact', required=False, ondelete='restrict')

Currently the output looks like this

Last_name First_name

And I want to change the order

First_name Last_name

I tried to do this using a compute method in my field declaration

compute='_compute_company_contact_id_name'


@api.depends('company_contact_id')

def _compute_company_contact_id_name(self):
 if self.company_contact_id :
  self.company_contact_id = u'%s %s'.format(
self.company_contact_id.first_name,
self.company_contact_id.name )

After that the field is not displayed anymore.


What is the correct way to do this ?


Thanks.

 


アバター
破棄

By default, Odoo allows searching customers only by name and displays only the name in Many2One fields. This module enhances the Many2One search and display functionality by enabling users to search using multiple fields (Phone, Email, Mobile, etc.) and display multiple values directly inside the Partners Many2One selection.
https://apps.odoo.com/apps/modules/17.0/mh_partner_search_and_display_multiple_field