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

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

Avatar
Zrušit
Autor Nejlepší odpověď

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
Zrušit

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

Nejlepší odpověď

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

Avatar
Zrušit
Nejlepší odpověď

You can also use @api.multi

Avatar
Zrušit
Related Posts Odpovědi Zobrazení Aktivita
1
led 17
6646
1
srp 25
367
1
srp 25
344
4
čvc 25
1689
1
čvc 25
962