Passa al contenuto
Menu
È necessario essere registrati per interagire con la community.
La domanda è stata contrassegnata
3 Risposte
17884 Visualizzazioni

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

Avatar
Abbandona
Autore Risposta migliore

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
Abbandona

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

Risposta migliore

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

Avatar
Abbandona
Risposta migliore

You can also use @api.multi

Avatar
Abbandona
Post correlati Risposte Visualizzazioni Attività
1
gen 17
6683
0
ago 25
168
1
ago 25
615
1
ago 25
505
4
lug 25
1841