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

I'm adding a Many2one field to my model as the following code:

cour_exec       =   fields.Many2one('cour.modl')


But when I render the field in a view appears like this

cour.modl,3 (the model name, id of the entry).


I want to show just one field on the form, the description of related to that id, I've been trying to use the options for other type of fields but i don't have the desired output.


Ả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

Câu trả lời hay nhất

It looks like you may need to define a "_rec_name" for your custom model. That will be used as the default display name for records of that model. You could always define a "name_get" method if you want a more custom display name.


So if the name you want to see for those records is "description" field, you would see something like this on your "cour.modl" model:


class CourModl(models.Model):
_name = 'cour.modl'
_rec_name = 'description'

description = fields.Char('Description')
 
Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
4
thg 7 23
2022
2
thg 7 17
3553
0
thg 3 15
3821
1
thg 9 22
2482
1
thg 3 18
9675