Skip to Content
Меню
Вам необхідно зареєструватися, щоб взаємодіяти зі спільнотою.
Це запитання позначене
3 Відповіді
17931 Переглядів

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

Аватар
Відмінити
Автор Найкраща відповідь

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

Аватар
Відмінити

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

Найкраща відповідь

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

Аватар
Відмінити
Найкраща відповідь

You can also use @api.multi

Аватар
Відмінити
Related Posts Відповіді Переглядів Дія
1
січ. 17
6722
2
серп. 25
196
0
серп. 25
301
1
серп. 25
689
Change position chatter Вирішено
1
серп. 25
534