Sign in
Try it free
  • Apps
    Websites
    Build great user experience
    • Website Builder
    • eCommerce
    • Blogs
    • Forums
    • Slides
    • Live Chat
    Sales
    Boost your success rate
    • Sales
    • CRM
    • Invoicing
    • Point of Sale
      • Shops
      • Restaurants
      • Hardware
    • Subscriptions
    • Sign
    Operations
    It's all about efficiency
    • Accounting
    • Project
    • Human Resources
      • Recruitment
      • Employees
      • Expenses
      • Appraisal
      • Fleet
      • Leaves
    • Inventory
    • Purchase
    • Manufacturing
      • MRP
      • PLM
      • Maintenance
      • Quality
    • Helpdesk
    Productivity Tools
    Great Tools = Happy People
    • Communication
      • Discuss
      • Mailing Lists
      • Notes
    • Timesheet
    • Email Marketing
    • Events
    • Survey
    • Appointments
    • Marketing Automation
    Third party apps | Odoo Studio | Odoo Cloud Platform NEW
  • Tour
  • Pricing
  • Community
  • Docs

Odoo Help


Odoo is the world's easiest all-in-one management software. It includes hundreds of business apps:
CRM | e-Commerce | Accounting | Inventory | PoS | Project management | MRP | etc.

Take the tour
Help
  • Trending
  • Newest
  • People
  • Tags
  • Badges
Ask a Question
0

Importing records--is there an option to create a related record if it does not exist yet?

import
By
Steve Stachurski
on 9/10/14, 2:07 PM • 2,097 views

I'm trying to import data from a flat CSV file, but the CSV file contains some relational information. The rows mostly represent "contacts" but contacts also have sales people associated with them, companies, etc.

So far my database is completely empty of any records and I want to start by importing contacts. When trying to validate the file, I get a bunch of errors like, "No matching record found for name 'Foo Bar' in field 'Salesperson'". Is it possible to configure the import process to create a matching salesperson and link up the records?

I guess the alternative, to do things the way openerp/odoo expects, is to kind of look at the graph of the relationships of contacts and import records from the "outside -> in" in the hierarchy.

  • Flag
  • Reply
  • Comment
  • Share
0
paul
On 9/12/14, 10:46 AM

Yes, generically the import process has the ability to create related records via the csv import.  For examle, I create related orderpoint records when I import new products.  I haven't tried to import your specific example of contacts and sales people. I recommend creating a few test contact and salesperson (users) records via the standard user interface then exporting those records to see how OpenERP formats the csv file.

  • Flag

I tried going to contacts, making a selection from the list and exporting. I chose to export the fields Salesperson, Name and Notes. Salesperson because I wanted to figure out how to relate contacts to sales people, Name because it's required, and Notes just because. The resultant file was called res.partner.csv which is a little weird...I wanted to export Contacts, not Partners, and I thought these record types were distinct. Also, the Salespeson field seems to have been exported as user_id/id, and filled with values like __export__.res_users_9, so this does not really help with setting up a format to import and create new sales people during contact import time. I'm assuming even if I replaced the ID number for a given user_id/id field, to a new one, that would not work because it does not include information like the sales person's name. Indeed, if I use the given csv file format and try to import a new one containing one row with a new user_id/id, I get this message: "No matching record found for external id '__export__.res_users_90' in field 'Salesperson' at row 2" where 90 is an ID for a user who doesn't exist yet. odoo seems to have identified user_id/id header to import into Salesperson / External ID field.

Flavor Dynamics, Steve Stachurski
on 9/12/14, 11:00 AM

The reason that the export file starts with res.partner is that the database model that stores contacts is called "res.partner" (fyi, you can see the respective model used by looking at the URL parameter 'model'). In addition, following similar reasoning...the Salesperson foreign key is stored in a field called 'user_id' of the res.partner model. So, that is why the export field starts with 'user_id'. When importing a related record (like Salesperson) as part of the contact import you may not be able to define the id of the new salesperson records (you will have to let OpenERP generate the id upon record creation). But you should still be able to define attributes of the salesperson (e.g. name, etc.) via this import of the contact csv file.

paul
on 9/12/14, 11:19 AM

This is only tangentially related but maybe you can answer this for me: I was under the impression that contacts and partners were distinct types in odoo. Actually you have to install a separate app to get support for "just plain contacts." I was planning on importing all records from my old CRM system as contacts and then only converting those that matched the condition of what it means to be "partner" into the partner model--for example a customer, supplier, or qualified lead. So what is it that distinguishes contacts from partners?

Flavor Dynamics, Steve Stachurski
on 9/12/14, 11:34 AM

"you should still be able to define attributes of the salesperson (e.g. name, etc.)" I'm sorry if exactly *how* I should do this should be obvious, but I can't figure it out. I've tried column headers like user_id/name, user_name/name, in an attempt to figure out how to traverse model relationships but odoo odes not seem to know what I'm trying to do, or if I just tell odoo to import that column as "Salesperson", then I get the same error, No matching record found for name 'Foo' in field 'Salesperson' at row 2.

Flavor Dynamics, Steve Stachurski
on 9/12/14, 11:37 AM

hmm, you are correct about not being able to import salesperson details info. usually there will be dropdown selections in the import screen for the additional details of the related entity (e.g. user_id/name). but I can't find them for this import. ....so you're not going crazy.

paul
on 9/12/14, 12:16 PM

In regards to your tangential question about contacts vs partners...both are derived from the same database model of res.partners. The difference between the two is more based on how they are used in OpenERP. After looking at the "contacts" app it only adds more views (forms and menus) of the same res.partner database records. The term 'partner' is sorta the generic term used by OpenERP to represent 3rd party entities (e.g. not Company or users). For example, a partner record can either be a Customer and/or Supplier. I would say that Partners usually represent the entity with whom the Company does business. Contacts provide for the mechanism of relating res.partner records to each other. For example, if John Doe is the sales manager of a supplier then you could create a "Contact" for John Doe and relate him to the existing supplier Partner record.

paul
on 9/12/14, 3:11 PM
  • Comment

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.

Register

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

Thanks for your subscription!
1 follower(s)

Stats

Asked: 9/10/14, 2:07 PM
Seen: 2097 times
Last updated: 3/16/15, 8:10 AM
Community
  • Github
  • Download
  • Runbot
  • Translations
  • Mailing Lists
  • Forum
Services
  • Odoo Cloud Platform
  • Support
  • Upgrade
  • Find a partner
  • Become a partner
  • Training center
  • Education
  • Security
About us
  • Our company
  • Contact
  • Events
  • Blog
  • Customers
  • Jobs
  • Legal | Privacy
  • English
    • 简体中文
    • Nederlands
    • Français
    • Deutsch
    • Italiano
    • Português (BR)
    • Español

Odoo is a suite of open source business apps that cover all your company needs: CRM, eCommerce, accounting, inventory, point of sale, project management, etc.

Odoo's unique value proposition is to be at the same time very easy to use and fully integrated.

Website made with

Live Webinar on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Watch now