Openerp 7.0 import FAQ

Source: Internet
Author: User
Tags psql
Frequently Asked Questions
Need to import data from an other application?

In order to re-create relationships between different records, you shoshould use the unique identifier from the original application and map it to the IDColumn in openerp. When you import an other record that links to the first one, use xxx/IDTo the original unique identifier.

The IDWill also be used to update the original import if you need to re-import modified data later, it's thus good practice to specify it whenever possible

What can I do when the import preview table isn' t displayed correctly?

By default the import preview is set on commas as field separators and quotation marks as text delimiters. if your CSV file does not have these settings, you can modify the file format options (displayed under the Browse CSV file bar after you select your file ).

Note that if your CSV file has a tabulation as separator, openerp will not detect the separations. You will need to change the file format options in your spreadsheet application. See the following question.

How can I change the CSV file format options when saving in my spreadsheet application?

If you edit and save CSV files in speadsheet applications, your computer's regional settings will be applied for the separator and delimiter. we suggest you use OpenOffice or libreoffice Calc as they will allow you to modify all three options (in 'Save As 'Dialog Box> check the box 'edit filter settings'> Save ).

Microsoft Excel will allow you to modify only the encoding when saving (in 'Save As 'Dialog Box> click 'tool' dropdown list> encoding tab ).

What's the difference between database ID and external ID?

Some fields define a relationship with another object. for example, the country of a contact is a link to a record of the 'country' object. when you want to import such fields, openerp will have to recreate links between the different records. to help you import such fields, openerp provides 3 mechanisms. you must use one and only one mechanisms per field you want to import.

For example, to reference the country of a contact, openerp proposes you 3 different fields to import:

  • Country: The name or code of the country
  • Country/Database ID: the unique openerp ID for a record, defined by the ID PostgreSQL Column
  • Country/external ID: the ID of this record referenced in another application (or the. xml file that imported it)

For the country Belgium, you can use one of these 3 ways to import:

  • Country: Belgium
  • Country/Database ID: 21
  • Country/external ID: Base. be

According to your need, You shoshould use one of these 3 ways to reference records in relations. Here is when you shoshould use one or the other, according to your need:

  • Use country: this is the easiest way when your data come from CSV files that have been created manually.
  • Use country/Database ID: You shoshould rarely use this notation. it's mostly used by developers as it's main advantage is to never have conflicts (You may have several records with the same name, but they always have a unique database ID)
  • Use country/external ID: use external ID when you import data from a third party application.

When you use external IDs, You can import CSV files with the "external ID" column to define the external ID of each record you import. then, you will be able to make a reference to that record with columns like "field/external ID ". the following two CSV files give you an example for products and their categories.

CSV file for categories
CSV file for products
What can I do if I have multiple matches for a field?

If for example you have two product categories with the child name "sellable" (ie. "Misc. products/sellable "&" other products/sellable "), your validation is halted but you may still import your data. however, we recommend you do not import the data because they will all be linked to the first 'sellable' category found in the product category list ("Misc. products/sellable "). we recommend you modify one of the duplicates 'values or your product category hierarchy.
However if you do not wish to change your configuration of product categories, we recommend you use make use of the external ID for this field 'category '.

How can I import a many21_relationship field (e.g. A customer that has multiple tags )?

The tags shoshould be separated by a comma without any spacing. for example, if you want you customer to be lined to both tags 'manufacturer' and 'retailer' then you will encode it as follow "manufacturer, retailer "in the same column of your CSV file.

CSV file for manufacturer, retailer
How can I import a one21_relationship (e.g. Several order lines of a sales order )?

If you want to import sales order having several order lines; for each order line, You need to reserve a specific row in the CSV file. the first order line will be imported on the same row as the information relative to order. any additional lines will need an addtional row that does not have any information in the fields relative to the order.

As an example, here is purchase. order_functional_error_line_cant_adpat.csv file of some quotations you can import, based on demo data.

File for some quotations

The following CSV file shows how to import purchase orders with their respective purchase order lines:

Purchase orders with their respective Purchase Order Lines

The following CSV file shows how to import MERs and their respective contacts

Customers and their respective contacts
Can I import several times the same record?

If you import a file that contains one of the column "external ID" or "Database ID", records that have already been imported will be modified instead of being created. this is very usefull as it allows you to import several times the same CSV file while having made some changes in between two imports. openerp will take care of creating or modifying each record depending if it's new or not.

This feature allows you to use the import/export tool of openerp to modify a batch of records in your favorite spreadsheet application.

What happens if I do not provide a value for a specific field?

If you do not set all fields in your CSV file, openerp will assign the default value for every non defined fields. but if you set fields with empty values in your CSV file, openerp will set the empty value in the field, instead of assigning the default value.

How to export/import different tables from an SQL application to openerp?

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

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. (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 origin 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.


 


From Weizhi note (wiz)

Openerp 7.0 import FAQ

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.