The solution to that is to choose one or two fields of the company that together form some sort of unique identifier.
Export just those fields to a file and import it into a spreadsheet workbook (let's call that Sheet_1). You'll see that an additional "External ID" column will have been created in Sheet_1, of the form __export__.res_partner_9999
.
Load your contacts into a second sheet in the workbook (Sheet_2), keyed with the columns that form the same unique identifier.
In a third sheet (Sheet_3), in a column entitled parent_id/id
, use the VLOOKUP function on a person in Sheet_2 to get the "External ID" for each company in Sheet_1. The search key to VLOOKUP will have to be concatenated from several columns if you can't find a truly unique company identifier in a single column. If you're starting from scratch you can invent a code of some kind before importing your company records and put it in the notes
column.
What you will have done is relate persons to companies using the pseudo-primary key (External ID
) of the company as the pseudo-foreign key (parent_id/id
) of the company for person records.
I have created a Google Spreadsheet that demonstrates simply what I describe above. For what it's worth: it also demos the very useful function for this kind of work QUERY(data, query, headers)
To use my example, do the following:
- Open the following link and save a copy for yourself to edit https://docs.google.com/spreadsheet/ccc?key=0AiVG6SoU001RdGFGdDNJM0lLQlM1QW5oQ1lwRXgwQkE
- Create a fresh, empty database in OpenERP V7 and make sure general settings permit you to create, export and import customers
- Download the sheet
ExportCompanies
as a CSV file
- Import it into the Customer's view of OpenERP
- Re-export those customers, but only the
Name
and Notes
attributes; the rest you already have, right?
- Import the resulting CSV file back into the spreadsheet and fix it up to look like the sheet
Example res.partner
- Edit
column G
of the Person
sheet to point to your imported res.partner
sheet, rather than the example
- Download the sheet
ExportPersons
as a CSV file
- Import it into the Customer's view of OpenERP
- Check that
Company #1236
has two contacts: Contact #10235
& Contact #10236
Hope that helps.