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

Hi, i would like to put 2 on_changes functions in the same field, and i don't know how to define it in the xml view. Thanks.

頭像
捨棄
最佳答案

If you need them for math computation try this



@api.onchange('field1', field2')

def onchange_name_of_onchange(self):

if self.field1 or self.field2:

self.fieldresult = self.field1 * self.field2


頭像
捨棄
最佳答案

+1 Odoo Honduras, thanks

頭像
捨棄
最佳答案

you can't do it using xml, you need to do it using the new api style for onchange, like:

@api.onchange('marital_status')

def onchange_m(self):

self.sex = 'm'

@api.onchange('marital_status')

def onchange_f(self):

self.sex = 'f'

頭像
捨棄
最佳答案

There is no way to do it, but there is no need to do 2 onchanges, you can do it once, and return more values, it depends on what you are trying to do.

頭像
捨棄
相關帖文 回覆 瀏覽次數 活動
1
10月 23
2050
2
10月 23
2295
2
8月 23
4306
4
8月 23
20630
3
10月 22
11086