Odoo Help


How to set country to customer

on 2/25/16, 1:35 AM 531 views

When user save the record Country will be Automatically store in database using Server action. eg:when i save the record of Customer,Country name will be Automatically store.

country_obj = self.pool.get('res.country') 
country_id = country_obj.search(cr, uid, [('name','=','india')])  
par_obj = self.pool.get('res.partner')
pat_id = par_obj.search(cr,uid,[('id', '=', uid)],context=context)
for ids in par_obj.browse(cr,uid,pat_id,context=context):
    if ids.country_id:
         par_obj.write(cr, uid,pat_id,{'country_id':country_id}, context=context)

Jusab Sida (jsi)

--Jusab Sida (jsi)--
| 2 1 5
Gandhinagar, India
--Jusab Sida (jsi)--

Jusab Sida (jsi)
On 2/25/16, 2:30 AM

Hi Vijay,

I have done that thing from front end through server action and automation action.

Here is server action:

country_obj = env['res.country'] 
country_id = country_obj.search([('name','=','India')])
if country_id:
country_obj = self.pool.get('res.country')
country_id = country_obj.search(cr, uid, [('name','=','India')])
 if country_id:
self.pool.get('res.partner').write(cr, uid, object.id, {'country_id':country_id[0]})

Now just create one record in Automation Actions(setting>Technical>Automation>) and put your server action in Server action to run call this server action in On Creation.

its display error : write() got multiple values for keyword argument 'context'

on 2/25/16, 2:41 AM

I have just updated my answer...Here i have tested in V8 in both style..both are working...can you please try again?

Jusab Sida (jsi)
on 2/25/16, 3:49 AM

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 platform 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.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 2/25/16, 1:35 AM
Seen: 531 times
Last updated: 2/25/16, 4:32 AM