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

When loading a register with a computed field (example, a new sale margin field computed out of price and cost), I see that it is not populated with the value. Why? and how can I make the value being displayed?

It is properly stored in database.


อวตาร
ละทิ้ง

you can use the onchange to trigger the computation for client side (form view)

คำตอบที่ดีที่สุด

Hello E.M.


To write a on_change method in .py file like this,

def on_change_emp_dept(self, cr, uid, ids, employee_id, context=None):
dept_id = False
if employee_id:
emp_pool = self.pool.get("hr.employee")
emp_obj = emp_pool.browse(cr, uid, employee_id, context=context)
dept_id = emp_obj and emp_obj[0].department_id.id or False
return {'value':{'department_id':dept_id}}

Invoke method in .xml file write like this,
<field name="employee_id" on_change="on_change_emp_dept(employee_id)" />
อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
4
พ.ค. 23
10506
1
ม.ค. 19
9592
0
ต.ค. 17
3419
0
พ.ย. 16
2694
0
ต.ค. 16
4951