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

With the old api we could return a domain in the on change function, is this possible with the new api?

الصورة الرمزية
إهمال
الكاتب أفضل إجابة

ok, its possible, but if the function has the decorator @api.one not works.

my error:

    @api.one
    @api.onchange('field_id')
     def onchange_field_id(self):
         relation_ids = [x.id for x in self.field_id.relation_ids]
         return {'domain':{'relation_id': [('id', 'in', relation_ids)]}}

but without @api.one works perfectly

    @api.onchange('field_id')
     def onchange_field_id(self):
         relation_ids = [x.id for x in self.field_id.relation_ids]
         return {'domain':{'relation_id': [('id', 'in', relation_ids)]}}

الصورة الرمزية
إهمال

Short update that it still works for V14/V15. Simply remove the @api.one there as this has been deprecated :-)

@Yenthe onchange that returns a domain is deprecated..

أفضل إجابة

Yes, Its possible an onchange method can return three items (warning, domain, value)

الصورة الرمزية
إهمال
أفضل إجابة

You can also use @api.multi

الصورة الرمزية
إهمال
المنشورات ذات الصلة الردود أدوات العرض النشاط
1
يناير 17
6679
0
أغسطس 25
129
1
أغسطس 25
570
1
أغسطس 25
482
4
يوليو 25
1818