Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

Update or modify object field value using self.pool in python

By
rais
on 4/2/15, 12:42 AM 3,968 views

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,


3

Openies Services

--Openies Services--
925
| 2 2 4
Vadodara, India
--Openies Services--

We provide Odoo Services.

Contact us on : contact@openies.com

Openies Services
On 4/2/15, 1:43 AM

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



Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 4/2/15, 12:42 AM
Seen: 3968 times
Last updated: 4/2/15, 5:45 AM