Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
1 Trả lời
1729 Lượt xem
Hello, I would like to know a way to order and limit the number of records in a list of a many to one field in Odoo 13
many2one field: aprob_id
order_by: name
limit: 5 records


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

Hi,

Use the following code to limit and order the records in the many2one field.

@api.onchange('aprob_id')

def _onchange_aprob_id(self):


    limited_records = self.env['related.model'].search([], limit=5,order='name')

    return {

         'domain': {'aprob_id': [('id', 'in', limited_records.ids)]}

        }

Hope it helps

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
2
thg 4 24
2777
2
thg 1 24
1222
1
thg 1 22
3373
0
thg 12 15
5209
0
thg 3 15
4545