تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
4 الردود
12876 أدوات العرض

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
أكتوبر 23
1953
2
أكتوبر 23
2154
2
أغسطس 23
4161
4
أغسطس 23
20487
3
أكتوبر 22
10964