İçereği Atla
Menü
Bu soru işaretlendi
3 Cevaplar
17804 Görünümler

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

Avatar
Vazgeç
Üretici En İyi Yanıt

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)]}}

Avatar
Vazgeç

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..

En İyi Yanıt

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

Avatar
Vazgeç
En İyi Yanıt

You can also use @api.multi

Avatar
Vazgeç
İlgili Gönderiler Cevaplar Görünümler Aktivite
1
Oca 17
6633
1
Ağu 25
268
1
Ağu 25
329
4
Tem 25
1678
1
Tem 25
953