Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
2 Trả lời
2838 Lượt xem
Hello, how could I limit the number of records shown by a many to one field and order the selection?


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

Hi,

You can use this module from OCA.It lets you define the number of records to be shown from settings.

https://apps.odoo.com/apps/modules/16.0/web_m2x_options/


Hope it helps

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất
Try this for limit and ordered records,

@api.onchange('many2one_field') def limit_many2one_records(self): limit = 5 limited_records = self.env['related.model'].search([], limit=limit,order='order_field') return { 'domain': {'many2one_field': [('id', 'in', limited_records.ids)]} }
Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 4 24
1780
1
thg 7 20
8755
2
thg 7 18
8650
1
thg 1 22
3446
0
thg 12 15
5320