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

Hi Guys I Need To Change Value Of Field According To Selection Field Changed So What The Best Way To Do It

Like (When I Chose The Employee Automatically Get His Wage in Another Field )

Thanks A lot

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

Use on_change function.

In python file:

_columns = {
        'name': fields.many2one('hr.employee', "Employee", required=True),
        'wage_amt': fields.float('Wage', digits=(16,2), required=True, help="Basic Salary of the employee"),
    }

    def onchange_employee_id(self, cr, uid, ids, employee_id, context=None):
        v = {}
        if employee_id:
            contract_sr = self.pool.get('hr.contract').search(cr, uid, [('employee_id','=',employee_id)], context=context)
            if contract_sr:
                contract_br = self.pool.get('hr.contract').browse(cr, uid, contract_sr, context=context)[0]
                v['wage_amt'] = contract_br.wage

        return {'value': v}

In XML file:

<field name="name" on_change="onchange_employee_id(name)"/>
<field name="wage_amt"/>
อวตาร
ละทิ้ง
ผู้เขียน

Thanks Ayyappan For Answer But Please If You Have Example I W'll Can Understand It

Related Posts ตอบกลับ มุมมอง กิจกรรม
2
ธ.ค. 17
16941
0
เม.ย. 15
3970
1
ธ.ค. 24
1593
0
มิ.ย. 19
3808
1
ส.ค. 18
8072