Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
3 Trả lời
17892 Lượt xem

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

Ảnh đại diện
Huỷ bỏ
Tác giả Câu trả lời hay nhất

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

Ảnh đại diện
Huỷ bỏ

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

Câu trả lời hay nhất

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

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

You can also use @api.multi

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 1 17
6687
1
thg 8 25
104
0
thg 8 25
209
1
thg 8 25
656
1
thg 8 25
513