Odoo Help


How do I import my contacts so they are placed within (linked to) the company for which they work?

Rex Thain
on 3/1/13, 10:46 AM 6,956 views

I have imported successfully imported companies via csv. I have created manually created a contact attached to a company and exported the csv file, but I see no field that can be mapped to the company they for which they work.

Is it not possible to import contacts within their companies via csv, if not how would you do it?




| 5 6 8
Cornwall, Canada

Analysing, designing, coding and mentoring since 1975. Kilobytes to terabytes. Punch cards to punchy sites. My OpenERP video series: http://www.youtube.com/playlist?list=PLq7op4J183lX44ZlXPiHxUpRvmmRDtxye My Google Speadsheets --> OpenERP Data Pump project: http://martinhbramwell.github.io/GData_OpenERP_Data_Pump My email (with spaces removed) : mhb . warehouseman @ gmail . com

On 3/1/13, 1:11 PM

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:

  1. Open the following link and save a copy for yourself to edit https://docs.google.com/spreadsheet/ccc?key=0AiVG6SoU001RdGFGdDNJM0lLQlM1QW5oQ1lwRXgwQkE
  2. Create a fresh, empty database in OpenERP V7 and make sure general settings permit you to create, export and import customers
  3. Download the sheet ExportCompanies as a CSV file
  4. Import it into the Customer's view of OpenERP
  5. Re-export those customers, but only the Name and Notes attributes; the rest you already have, right?
  6. Import the resulting CSV file back into the spreadsheet and fix it up to look like the sheet Example res.partner
  7. Edit column G of the Person sheet to point to your imported res.partner sheet, rather than the example
  8. Download the sheet ExportPersons as a CSV file
  9. Import it into the Customer's view of OpenERP
  10. Check that Company #1236 has two contacts: Contact #10235 & Contact #10236

Hope that helps.

Martin, Thanks for the detailed instructions, I will give them a try as soon as I can.

Rex Thain
on 3/1/13, 6:28 PM

Yeah! I'd like to know if I've skipped anything important. Please advise me of any confusions, ambiguities or lapses.

on 3/1/13, 6:50 PM

Were you successful?

on 3/5/13, 6:40 AM

I used excel rather than googledocs so the process was slightly different, however your explanation gave me an understanding of the concept. The import created the contacts within the company and as a separate contact also, notes came in with the contact as well. Unfortunately, I made a mistake when matching the contact to the company (sort function issue) and about half way through the list the contacts ended up miss assigned, so i will be doing it again.

But again the concept was sound and exactly what I need thanks so much for your help and fast response.

Rex Thain
on 3/5/13, 9:04 AM

This is great news. I'm glad I was able to help.

on 3/9/13, 6:14 AM

@Martin UPDATE...the import worked to get all the contacts in but the only user that can access them is the admin (it is also the only user that existed at the time of the import). I thought is was a bug problem and so I loaded the fix but it didn't make any difference. When I install new users they cannot access the imported companies or contacts, but any new companies or contacts that are installed can be accessed by the other users regardless of who created them. Any Suggestions???

Rex Thain
on 3/12/13, 9:34 PM

I see you have removed the check mark that accepted my answer, even though I did fully answer the question you asked. You even said "I have imported successfully imported companies via csv". Were they successfully imported or not? You now say that, "When I install new users they cannot access the imported companies or contacts." This is a new problem, unrelated to the one I answered thoroughly and correctly. You should consider asking for help with an entirely new question, leaving this one marked as having been correctly answered.

on 3/13/13, 1:42 PM

I have rechecked the answer as accepted, my thought was that if imported information can not be accessed it wasn't successfully imported. I created a fresh data base did a first level import (just the company not the related contact) and could not access the company list with a created user so there must be another issue. I have created another question to address it.

Rex Thain
on 3/13/13, 2:09 PM

Thank you. I appreciate your quick response. The new problem is strange and worrying, since I am busy with much the same work myself right now.

on 3/13/13, 2:27 PM

I had managed to get all my contacts imported through csv without specifying a company (since I couldn't get it to recognise them), thought I could just assign a company to the contacts later. But when I started doing that in OpenERP, as soon as I assigned a company to a contact, all their info except their name disappeared! Anyone know how to prevent that from happening?

Bob Schader
on 3/23/13, 12:19 PM

UPDATE: @Martin; @ Bob .I have discovered what might have been a "duh" to many, particularly our European users. There are two different "Companies" in OpenERP. The Company you can see when signed in with full admin privileges that you see under settings is the "Your Company". Since OpenERP supports multi-companies you create multiple Owned or "Your Companies". If you use settings/companies/import the system assumes these are all "Your Companies" so only users with access would see them. The companies (customer companies) I was wanting to import should be imported through (see below)

Rex Thain
on 3/28/13, 5:31 PM

(cont. from above) imported through Sales/Customers/Import, then you can follow the above answer and other users will be able to see. Remember that you must have the User can Import/Export box checked in General Settings and when you are at Sales/Customers you must be in list view or you can't see the import button. Also when you import the Companies you must have a column "Is a Company" and the field must be marked TRUE.

Rex Thain
on 3/28/13, 5:50 PM

Which field (when using the import wizard ) is being matched to the 'parent_id/id' field in the csv file? I've tried 'Related Company" and others like it but keep getting vakudatuib errors, or worse, a red error with no reason why its failed validation. Can anyone assist?

Michael Gardner
on 5/21/13, 10:37 PM
On 3/15/13, 6:47 PM

I know im an idiot but can you please expain to me how to do step 2 and 3. I searched through every menu and I dont see any kind of export option. I do see import options on list views for every section but I do not see any export option.

Specifically on step 2 I created a new blank database fine. I do not see where under settings it permit you to create, export and import customers. I only see the Import/Export - Allow users to import data from CSV file.
I am logged in as administrator, created a customer but still can't find export option.

Please help! If you can explain as if you are talking to a 4 year old that would be perfect! Thanks!

On 3/16/13, 4:27 AM

Hey Tony,

I think what you are missing is the following.

  1. Remember to enable the Technical Features check box under Settings - Users - Admin (or your User) - Access Rights Tab. Log out and log in to apply extra features. I found useful to enable this, as many options, in many modules don't show without this active.
  2. Go to Settings - General Settings - and check "Allow users to import data from CSV files"
  3. Now, you will be able to see the Import option and, if you check any fields, under the "More" top central dropdown menu, the Export option will appear.
  4. Remember that this options often appear inside each module and not in the Configuration or General Settings.
  5. And for example, in the customer option, under Sales - Customers. To see the Import/Export option, you have to change the view from Kanban View to List View, using the top right view icons.



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: 3/1/13, 10:46 AM
Seen: 6956 times
Last updated: 3/16/15, 8:10 AM