+ If you need to import data from different tables,
+ you will have to recreate relations between records
+ belonging to different tables. (e.g. if you import
+ companies and persons, you will have to recreate the
+ link between each person and the company they work
+ for).
To manage relations between tables,
+ you can use the "External ID" facilities of OpenERP.
+ The "External ID" of a record is the unique identifier
+ of this record in another application. This "External
+ ID" must be unique accoss all the records of all
+ objects, so it's a good practice to prefix this
+ "External ID" with the name of the application or
+ table. (like 'company_1', 'person_1' instead of '1')
+
As an example, suppose you have a SQL database
+ with two tables you want to import: companies and
+ persons. Each person belong to one company, so you
+ will have to recreate the link between a person and
+ the company he work for. (If you want to test this
+ example, here is a
+ dump of such a PostgreSQL database).
+ We will first export all companies and their
+ "External ID". In PSQL, write the following command:
+
copy
+ (select 'company_'||id as "External ID",company_name
+ as "Name",'True' as "Is a Company" from companies) TO
+ '/tmp/company.csv' with CSV HEADER;
+ This SQL command will create the following CSV file:
+
External ID,Name,Is a Company
+
company_1,Bigees,True
+
company_2,Organi,True
+
company_3,Boum,True
+ To create the CSV file for persons, linked to
+ companies, we will use the following SQL command in
+ PSQL:
copy (select
+ 'person_'||id as "External ID",person_name as
+ "Name",'False' as "Is a Company",'company_'||company_id
+ as "Related Company/External ID" from persons) TO
+ '/tmp/person.csv' with CSV
+ It will produce the following CSV file:
+
External ID,Name,Is a
+ Company,Related Company/External ID
+
person_1,Fabien,False,company_1
+
person_2,Laurence,False,company_1
+
person_3,Eric,False,company_2
+
person_4,Ramsy,False,company_3
+ As you can see in this file, Fabien and Laurence
+ are working for the Bigees company (company_1) and
+ Eric is working for the Organi company. The relation
+ between persons and companies is done using the
+ External ID of the companies. We had to prefix the
+ "External ID" by the name of the table to avoid a
+ conflict of ID between persons and companies (person_1
+ and company_1 who shared the same ID 1 in the orignial
+ database).
+ The two files produced are ready to be imported in
+ OpenERP without any modifications. After having
+ imported these two CSV files, you will have 4 contacts
+ and 3 companies. (the firsts two contacts are linked
+ to the first company). You must first import the
+ companies and then the persons.
+
+