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 ?
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) ]
| 相关帖文 | 回复 | 查看 | 活动 | |
|---|---|---|---|---|
|
1
9月 23
|
3910 | |||
|
1
12月 22
|
5141 | |||
|
0
10月 21
|
4784 | |||
|
2
3月 21
|
6848 | |||
|
2
3月 21
|
6015 |
1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.