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

Below is my code for field on_change 

My form view xml

<field name="x_project_id" on_change="onchange_project(x_project_id,partner_id)" string="Project" />

Python code is below:




def onchange_project(self, cr, uid, ids, project_id, client_id, context=None): if project_id: obj = self.pool.get('res.partner').browse(cr,uid,project_id,context=context) val1 = obj.name val2 = obj.x_project_value





Is there any way I can update res.partner by using similar to below 

self.pool.get('res.partner').update({'parent_id': client_id}) 


 Thanks,


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

If you wanted to update a record of particular model you can call write method. here is the sample code

partner_obj = self.pool.get('res.partner')
partner_obj.write(cr, uid, partner_ids, {'name': 'new_name'}, context=context)

when you write onchange method as per odoo v7 it should return dictionary. i.e.

 def onchange_project(self, cr, uid, ids, project_id, client_id, context=None):
         '''your code'''
return {'value': {'field': 'my value'}}



อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
2
ก.พ. 22
4515
0
มี.ค. 25
490
1
เม.ย. 24
1281
4
เม.ย. 24
172883
0
ธ.ค. 23
1479