Skip to Content
Meniu
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
Această întrebare a fost marcată
3 Răspunsuri
17822 Vizualizări

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

Imagine profil
Abandonează
Autor Cel mai bun răspuns

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

Imagine profil
Abandonează

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

Cel mai bun răspuns

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

Imagine profil
Abandonează
Cel mai bun răspuns

You can also use @api.multi

Imagine profil
Abandonează
Related Posts Răspunsuri Vizualizări Activitate
1
ian. 17
6652
1
aug. 25
414
1
aug. 25
374
4
iul. 25
1706
1
iul. 25
972