Odoo Help


csv import: data with relation

Sven Gehr
on 8/21/13, 3:20 AM 2,415 views


I test still various data imports. I do I create a supplier and export these. When I try to import it again I get the error:

null value in column "state" violates not-null constraint in Line 2

In the export-file exists in the the column:


with the value:


So there is the field "state" in the parter contact. They are in the table:


searched data set has the id 58.

How can I import this relation?

with best regards Sven

Sven Gehr
On 8/21/13, 5:50 AM

the 58 was just an example. The question is what value should I put in the csv file into the column?

Better if you don't import that column if you don't have any value there. set the column as don't import also do the same to the state_id. the csv will import because these fields are not required fields for supplier. The only required field in supplier is the name field. the other can be excluded during import.

on 8/21/13, 5:56 AM
On 8/21/13, 5:14 AM

Did you try to import it into another database? If you did, it will tell you just that because you have not created the state_id in the new database. To import into a new database, you will need to export the state name, state_id and the state state_id/id from the first database separately and import it into the new database then when you try again to import the supplier it will not give you this error because the state_id/id would have been added to the database

I want to import the relation partner -> state. if I e.g. import the german states. I look in the table "res_country" and look for the line with germany. I realize the id and write it in the colum "country_id" in my german_stats.csv. After the import openerp show me all german stats with the relation to germany. Why does that not work for the relation partner to the state?

Sven Gehr
on 8/21/13, 6:13 AM

have you imported the states already?

on 8/21/13, 6:46 AM

yes states are in the table. I can view with pgadmin and locate the id

Sven Gehr
on 8/21/13, 7:00 AM

Export the states alone and get their ids without the countries. Then use these ids instead. That should work. When you import the states OpenERP generates ids them. Alternatively you can import state_id instead which are the names of the states and don't import state_id/id

on 8/21/13, 7:03 AM

I have no ids in the csv file (states.csv) used. Only

code,name,country_id BW,Baden-Württemberg,58 BY,Bayern,58 ....

Sven Gehr
on 8/21/13, 10:26 AM

something like __export__.res_partner_58 is an Id plus if you are importing the state and you already have the state_id/id you should not import the state column anymore unless you have all the right states filled. Omit the state column and try again with only state_id/id. if you export the state names only the first column in the export csv usually have the id for each state name

on 8/21/13, 11:09 AM

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

0 follower(s)


Asked: 8/21/13, 3:20 AM
Seen: 2415 times
Last updated: 3/16/15, 8:10 AM