跳至內容
選單
此問題已被標幟
1 回覆
3786 瀏覽次數

Hi, 

I would like to know how can I achieve this

I have a field called demofield that has the value 10 for example

And I would like that my field demofield2 has as default the value of the first demofield but it can be editable.

I have tried with  @api.onchange but always set the value of demofield2 as demofield and I can't change it.

Thank you for your help

頭像
捨棄
最佳答案

You have to set your demofield2 as a computed field;

demofield2 = fields.Float(compute='_compute_demofield2', store=True)
@api.depends('demofield')
def _compute_demofield2(self):
    self.demofield2 = self.demofield

The store=True parameter is very important to make the field editable.

頭像
捨棄
相關帖文 回覆 瀏覽次數 活動
1
5月 22
3871
1
12月 21
6300
0
10月 21
2865
1
10月 21
3625
0
4月 21
1978