Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
1 ตอบกลับ
8805 มุมมอง

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

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

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

Related Posts ตอบกลับ มุมมอง กิจกรรม
0
พ.ย. 22
80
Domain with inherited field แก้ไขแล้ว
1
ต.ค. 22
3817
1
มิ.ย. 22
7274
Many2many domain not working แก้ไขแล้ว
1
ก.ค. 21
2824
Many2many domain not working แก้ไขแล้ว
1
ก.ค. 21
4285