Siirry sisältöön
Menu
Sinun on rekisteröidyttävä, jotta voit olla vuorovaikutuksessa yhteisön kanssa.
Tämä kysymys on merkitty
3 Vastaukset
17944 Näkymät

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

Avatar
Hylkää
Tekijä Paras vastaus

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
Hylkää

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

Paras vastaus

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

Avatar
Hylkää
Paras vastaus

You can also use @api.multi

Avatar
Hylkää
Aiheeseen liittyviä artikkeleita Vastaukset Näkymät Toimenpide
1
tammik. 17
6722
2
elok. 25
263
0
elok. 25
335
1
elok. 25
724
1
elok. 25
555