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

i want to get the value 'nom' from model 'wilaya' in my model 'bien' 

in model bien:

wilaya_id=fields.Many2one(comodel_name="immobilier.wilaya")
in model wilaya:
num = fields.Integer()
nom=fields.Char()
bien_ids=fields.One2many(comodel_name="immobilier.bien",inverse_name="wilaya_id")
when i run it gives me the wilaya ID as a selection, how do i get 'nom' instead of ID
Ảnh đại diện
Huỷ bỏ

i solved it by adding _rec_name in the model

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

Hello,

You can try:

     wilaya_id = fields.Many2one('wilaya_model_here', 'Relation field to model wilaya')
     nom= fields.Char(related=' wilaya_id.nom')

Hope it helps you

Best regards

PM

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
2
thg 2 25
5900
1
thg 12 24
1451
1
thg 11 22
15968
3
thg 8 22
12995
2
thg 8 22
4478