Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
4 Odpovědi
12984 Zobrazení

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.

Avatar
Zrušit
Nejlepší odpověď

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


Avatar
Zrušit
Nejlepší odpověď

+1 Odoo Honduras, thanks

Avatar
Zrušit
Nejlepší odpověď

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'

Avatar
Zrušit
Nejlepší odpověď

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.

Avatar
Zrušit
Related Posts Odpovědi Zobrazení Aktivita
1
říj 23
2071
2
říj 23
2312
2
srp 23
4325
4
srp 23
20649
3
říj 22
11099