跳至內容
選單
此問題已被標幟
3 回覆
17876 瀏覽次數

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
6679
0
8月 25
126
1
8月 25
565
1
8月 25
478
4
7月 25
1811