跳至内容
菜单
此问题已终结
3 回复
17805 查看

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

形象
丢弃
相关帖文 回复 查看 活动
1
1月 17
6637
1
8月 25
292
1
8月 25
333
4
7月 25
1680
1
7月 25
957