Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
3 Odpowiedzi
10717 Widoki

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.

Awatar
Odrzuć
Najlepsza odpowiedź

Hi Steve,

I think this video can help you:

https://www.youtube.com/watch?v=UOBxxnYDIsM&list=PLSKcWRTtEl5qzvRaI-VTGavfReiHS_EEb&index=1

Awatar
Odrzuć
Najlepsza odpowiedź

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.

Awatar
Odrzuć
Autor

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.

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.

Autor

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?

Autor

"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.

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.

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.

Powiązane posty Odpowiedzi Widoki Czynność
2
maj 25
918
4
maj 25
4429
1
sie 24
1902
1
lut 24
2627
3
paź 23
2437