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

I have a Many2one field which is linked to another model:

field_id = fields.Many2one(''model.name")

Then I use this, to make it related with a field.

related_field = fields.Integer(related="field_id.computed_field")


I also made the default of Many2one field by using this function:

def defaultm2o(self):
return self.env['hotel.room'].search([], limit=1).id

Now, why my Many2one field won't give values to my related fields unless I specify it to xml?

and most importantly, how do I make it that I may not include it in xml file?

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

Hi,

I see that you have given related=“field_id.computed_field”. Computed field only works when the view loads. May be that’s why it is working only when you give xml. You can give the field in xml but give the attribute invisible=“1”, which hides the field from view.

Regards

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 8 19
5923
8
thg 4 23
71310
6
thg 11 19
4047
0
thg 2 23
2089
0
thg 1 25
1264