Skip to Content
Menú
This question has been flagged
3 Respostes
17791 Vistes

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

Avatar
Descartar
Autor Best Answer

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
Descartar

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

Best Answer

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

Avatar
Descartar
Best Answer

You can also use @api.multi

Avatar
Descartar
Related Posts Respostes Vistes Activitat
1
de gen. 17
6625
1
d’ag. 25
144
1
d’ag. 25
300
4
de jul. 25
1634
1
de jul. 25
923