跳至内容
菜单
此问题已终结
2 回复
2849 查看
Hello, how could I limit the number of records shown by a many to one field and order the selection?


形象
丢弃
最佳答案

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

形象
丢弃
最佳答案
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)]} }
形象
丢弃
相关帖文 回复 查看 活动
1
4月 24
1782
1
7月 20
8763
2
7月 18
8660
1
1月 22
3455
0
12月 15
5341