跳至內容
選單
此問題已被標幟
1 回覆
1730 瀏覽次數
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


頭像
捨棄
最佳答案

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

頭像
捨棄
相關帖文 回覆 瀏覽次數 活動
2
4月 24
2781
2
1月 24
1223
1
1月 22
3373
0
12月 15
5211
0
3月 15
4550