i've created many2many field with hr.employee in custom model,
but i need to get the ids of the selected many2many fields,
any idea how to do that ?
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
i've created many2many field with hr.employee in custom model,
but i need to get the ids of the selected many2many fields,
any idea how to do that ?
Hi @loay elhaj
let suppose you have created the field employee_ids in your cutom model as test.
employee_ids = fields.Many2many('hr.employee', 'employee_test_rel', 'test_id', 'emp_id', string='Employees')
to get the ids of the selected employees in many2many field, you have to do
self.employee_ids.ids
this will return a list of selected employee ids ([6,889,90] for example)
Thank you it's working,
but I'm wondering can ORM method .browse accept passing list as filter for searching ?
Yes @loay elhaj self.browse only accept LIST OF IDS or RECORD ID
[ self.browse([7, 18, 12]) OR self.browse(2) ]
Buat akun sekarang untuk menikmati fitur eksklufi dan agar terlibat dengan komunitas kami!
Daftar| Post Terkait | Replies | Tampilan | Aktivitas | |
|---|---|---|---|---|
|
|
1
Sep 23
|
2478 | ||
|
Many2Many filter | Odoo V14 | Odoo Studio
Diselesaikan
|
|
1
Des 22
|
3799 | |
|
|
0
Okt 21
|
3489 | ||
|
ver.14: Many2one field how to filter from Many2many
Diselesaikan
|
|
2
Mar 21
|
5316 | |
|
|
2
Mar 21
|
4493 |