コンテンツへスキップ
メニュー
この質問にフラグが付けられました
1 返信
22147 ビュー

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'}}



アバター
破棄
関連投稿 返信 ビュー 活動
2
2月 22
4653
0
3月 25
796
1
4月 24
1388
4
4月 24
173195
0
12月 23
1661