コンテンツへスキップ
メニュー
この質問にフラグが付けられました
3 返信
17890 ビュー

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
6685
1
8月 25
87
0
8月 25
193
1
8月 25
653
1
8月 25
513