Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
3 Odpowiedzi
17983 Widoki

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

Awatar
Odrzuć
Autor Najlepsza odpowiedź

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

Awatar
Odrzuć

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

Najlepsza odpowiedź

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

Awatar
Odrzuć
Najlepsza odpowiedź

You can also use @api.multi

Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
1
sty 17
6740
2
sie 25
264
2
sie 25
314
2
sie 25
473
0
sie 25
446