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

Trouble importing state into res.partner

By
Chris Jones
on 8/29/13, 11:11 PM 1,750 views

I have a basic Python script that uses the xmlrpclib library to remotely create a customer in OpenERP 7.0.

customer = { 'comment': 'test notes', 'street2': None, 'phone': '605-730-1580', 'street': '24246 450th Ave', 'city': 'Pukwana', 'name': 'Karla Burns', 'zip': '57373', 'country': 'United States', 'Company': None, 'email': 'email@gmail.com', 'Active': 'TRUE', 'res.country.state': 'South Dakota', 'is_company': 'TRUE' } customer_id = sock.execute(dbname, uid, pwd, 'res.partner', 'create', customer)

The code runs fine and it creates the record but I can't get the State or Country to show up. The customer form is looking for res.partner.state_id and res.partner.country_id but those are integer fields and I don't know the int value for each state. How do I lookup the int of a state from res.country.state and feed it to res.partner.state_id?

0
martin mueller
On 9/20/13, 7:20 PM

You could use:

args = [('code', '=', 'US')] 
id = sock.execute(dbname, uid, pwd, 'res.country', 'search', args)

to get the id of the country and

args = [('code', '=', 'SD'), ('country_id', '=', 235)] 
id = sock.execute(dbname, uid, pwd, 'res.country.state', 'search', args)

to get the state id, then feed those into the customer data.

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

0 follower(s)

Stats

Asked: 8/29/13, 11:11 PM
Seen: 1750 times
Last updated: 3/16/15, 8:10 AM