Skip to Content
Menú
This question has been flagged
1 Respondre
1769 Vistes
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


Avatar
Descartar
Best Answer

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

Avatar
Descartar
Related Posts Respostes Vistes Activitat
2
d’abr. 24
2799
2
de gen. 24
1257
1
de gen. 22
3396
0
de des. 15
5257
0
de març 15
4586