콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
1 회신
22529 화면

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
5069
0
3월 25
1242
1
4월 24
1679
4
4월 24
173924
0
12월 23
2015