Skip ke Konten
Menu
Pertanyaan ini telah diberikan tanda
1 Balas
2436 Tampilan

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?

Avatar
Buang
Jawaban Terbai

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

Avatar
Buang
Post Terkait Replies Tampilan Aktivitas
1
Agu 19
6035
8
Apr 23
71696
6
Nov 19
4186
0
Feb 23
2247
0
Jan 25
1422