Skip to Content
Menu
This question has been flagged
1 Atsakyti
1742 Rodiniai
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


Portretas
Atmesti
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

Portretas
Atmesti
Related Posts Replies Rodiniai Veikla
2
bal. 24
2785
2
saus. 24
1228
1
saus. 22
3378
0
gruod. 15
5226
0
kov. 15
4551