Перейти к содержимому
Меню
Чтобы взаимодействовать с сообществом, необходимо зарегистрироваться.
Этот вопрос был отмечен
3 Ответы
17832 Представления

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
6666
1
авг. 25
438
1
авг. 25
420
4
июл. 25
1723
1
июл. 25
983