Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
2 Trả lời
5895 Lượt xem

Disclaimer: Total newbie.


I have a two tables, routes (ruta) and drivers (conductor), each route has an assigned driver so in the route model I created a many2one field linking both tables:


conductor_id = fields.Many2one('produccion.conductor', required=True)
conductor_nombre = fields.Char(related='conductor_id.nombre', string="Conductor")


I can succesfully display the drivers name on a list by adding the conductor_nombre field, however, on a form, the dropdown for the driver field displays the driver ID, how do I make it dispaly the driver´s name only?


<field name="conductor_id"/>
Ảnh đại diện
Huỷ bỏ

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

Tác giả Câu trả lời hay nhất

nevermind, in the conductores model I wasnt defining a 'name' field. 


Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Hi,

Just to add along with your answer, either you can define a field with the name as name or you can use rec_name to specify which field to show in the drop down.

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


Thanks

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 12 24
1449
1
thg 11 22
15958
3
thg 8 22
12977
2
thg 8 22
4470
0
thg 7 22
836