hai, i need to populate a many2one field with condition i cant use domain filter here,i want to take some data filter from many2many table,so i need to write a conditonal populate for many2one field, Please Help me. Regards jamshid k
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- 客户关系管理
- e-Commerce
- 会计
- 库存
- PoS
- Project
- MRP
此问题已终结
1
回复
8753
查看
You can try something like below: In custom object of your .py file:
def _get_emp_type_domain(self, cr, uid, ids, field_name, arg, context=None):
if ids:
record_id = ids[0]
emp_type_list = self.pool.get('many2many_table').browse(cr, uid, ids, context=context)
list = []
for id in emp_type_list:
list.append(id.name.id)
return {ids[0]: [('id','in',list)]}
_columns = {
'emp_type': fields.many2one('hr.job', 'Employee Group'),
'domain_field': fields.function(_get_emp_type_domain, type='char', size=255, method=True, string="Domain"),
In xml file:
<field name="domain_field" invisible="1"/>
<field name="emp_type" domain="domain_field"/>
Hope this may help you.
Thanks Nehal
相关帖文 | 回复 | 查看 | 活动 | |
---|---|---|---|---|
|
0
11月 22
|
80 | ||
|
1
10月 22
|
3764 | ||
|
1
6月 22
|
7229 | ||
|
1
7月 21
|
2793 | ||
|
1
7月 21
|
4230 |