You are on page 1of 16

v.6.

Data Import
General Stuff about import in OpenERP
Defining, Changing & Discovering ids
Mapping partners
Mapping contacts
Mapping products
OpenERP 6.1 Import/Export

General Stuff about import in OpenERP

In OpenERP, you have the possibility to import your data from other software at the only
condition that you have to export them in a CSV format from your other software.

When trying to import data in OpenERP, it is important to understand the meaning of the
different fields to be able to do the mapping between OpenERP fields and the different data
from the other software.

ID (see Defining, Changing & Discovering ids in OpenERP 6.1)


Field Column Meaning
ID id ID has a global meaning for any objects you want to import in OpenERP.
This is the XML ID. It is a record created in the object ir.model.data and can be
useful when you want to export data from one database and import in another
database. The link with the right object will be automatically done with this
field.

Process

1. Fill one element in the object in OpenERP you want to import with the field you will have
to mention in the import phase
2. Export this element and select the field you have filled in the previous step to have the
structure of the CSV file
3. Open the CSV file and fill it with all your information
4. Import your data

Important Remarks

default & automatic values


When you create a partner or a product, some fields are filled by the system automatically.
For those fields, you do not have to mention them in your CSV file. They will be automatically
added by the system. But if you want to change those default values, you can do it by adding
the column in your CSV file and fill it with the right information.
Example: The minimum information to mention in your CSV file is the name of the partner. All
the other fields will be filled by the system with default values.

Data (& ids) already defined


Some data are already in the system, correct term must be used in the import!
Language is written en_US, you have to enter en_US not English.
Country is written base.be, you have to enter base.be not Belgium
Currency is written base.EUR, you have to entre base.EUR not Euro
To find the correct terms to use, you can activate the debug mode (top right corner, About) or
export from OpenERP.

1
OpenERP 6.1 Import/Export

many2one
When you want to put your products in a category, you have to mention only the id of the
category in the CSV file. The different categories must exist before you try to import your
product. If they are not present, you will get an error because OpenERP will try to refer to
something that isnt existing.

Note that to add a product in the category Sellable which is a child of All products category,
you have to mention in your CSV file Sellable and not All products / Sellable that is exported
from OpenERP.

one2many and many2many


When you want to put your partners in some categories, you have to mention the ids of the
categories in the CSV file. The different categories must exist before you try to import your
partner. If they are not present, you will get an error because OpenERP will try to refer to
something that isnt existing.

To refer several categories for only one partner, you can separate with "," (separator must not
be defined as ,).

Possible errors

1. You try to refer to something that is not existing in OpenERP


o You can have this error when you try to refer to something which is displayed in a
many2one field (Example: product category)
o Solution: Create the item that does not exist and retry to import.
(if you import products and need categories of products, first import categories)

2. You reference to something which is not recognized by OpenERP


o You may have tried to import some data with an incorrect format. It can happen
for the selection fields (example: product type)
o Solution: you can activate the debug mode (top right corner, About) or export
an example to see what is the correct information to mention in your CSV file

3. The column name is incorrectly matched


o You could have chosen an incorrect column name when importing
o Solution: export example data from OpenERP to see the correct column name
you have to choose during import

4. The CSV file is not readable


o Solution: Change import options: encoding, field separator, text delimiter
(By default: separator = , / delimiter = / Encoding = UTF-8 )

2
OpenERP 6.1 Import/Export

Defining, Changing & Discovering ids in OpenERP 6.1


When importing list of records, some CSV columns might not be recognized by OpenERP. Sometimes
you just need to look in the proposed list to find the correct mapping but sometimes columns (like
country name or category name) can not be imported by OpenERP.

Ex: I want to import the list of partners but the columns Categories of partners and Countries
are not recognized and cant be imported. .

In fact, these columns can only be imported by id. The id is either set at a default value by
OpenERP or defined when you import the data (by the column id).

How is it possible to define or change the ids in order to have user-friendly ones?

Did you create or import categories of partners in OpenERP?


- No solution 1
- Yes solution 2

(1) Defining id when importing


If categories of partners havent been imported or created yet.

Before importing
(in categories CSV file)

Duplicate the column containing the NAME of categories of partners.

When importing categories of partners


(in Sales > Configuration > Address Book > Partner Categories)

When defining the mapping between CSV columns and OpenERP fields, choose id for the
duplicated one.

Check partners CSV file


(in partners CSV file)

Records concerning Partner Categories in the partners CSV file have to named Retailers
(retailers =name of the category) or Consumers to be imported in OpenERP as Retailers or
Consumers.

When importing list of partners


(in Sales > Configuration > Address Book > Partner Categories)

Column Category of partner can now be imported.

3
OpenERP 6.1 Import/Export

2) Changing ids after import


If categories of partners have already been imported or created.

!!! In this case external identifiers have been defined automatically by OpenERP.

Retrieve ids (by exporting)


(in Sales > Configuration > Address Book > Partner Categories)

Export the list (of categories of partners) and the external identifier will appear in the CSV file, in
the column id (ex: __export__res_partner_category_1)

There are now two sub-solutions:

a) Change ids in Open ERP

Create a new menu for configuration of ids


(in Settings > Customization > Database Structure > Models)

o Search & Select Model = ir.model.data


o Click Create a Menu
o Enter Menu Name = Data model (for example)
Parent Menu = Sales
! Refresh the page !

Change ids
(in Sales > Configuration > Sales > Data Model ( = new menu created))

o Search Model Name = res.partner.category


o Select the id to modify (see Retrieve ids)
o Edit External Identifier* = Retailers (for example)
Module** = Cat (for example)

* External Identifier is the name the real name of the category.


** Module will appear before the external identifier.

Modify partners CSV file


(in partners CSV file)

Records in the partners CSV file have to be Cat.Retailers to be imported in OpenERP as


Retailers.
In general Module.External Identifier

When importing list of partners


(in Sales > Configuration > Address Book > Partner Categories)

Column Category of partner can now be imported.

4
OpenERP 6.1 Import/Export

b) Export - Delete - Modify - Import


There is another solution to change the id of existing data in OpenERP.

1) Export the list from OpenERP (see retrieve ids)


For example list of countries: Countries are by default referenced by base.code with
code being a two letters country code (be for belgium, de for germany, etc.). So while
importing partners list, countries have to be named like this.

2) Delete the list (of countries) in OpenERP.


The records (countries) cant be related to other elements in order to be deleted! For
example, USA is the only country related to Federal States even if no demo data is loaded. In this
case, to import USA, federal states also need to be imported and deleted in OpenERP.

3) In the CSV file, modify the column id by copying column name in it.
Country name = External Identifier

4) Go back to OpenERP and import the CSV file (mapping the new id column with id).

Column Country can now be imported. (mapped with address/country_id/id)


The external identifier of records (countries) have changed in OpenERP and are now equal to
the name of the countries.

Note:
You also easily find ids of fields by going in the developer mode:
- Click on About in the top right corner,
- Click on Activate the developer mode

Now when you are on an object, go to View Log and you can see the XML ID

5
OpenERP 6.1 Import/Export

Mapping partners in OpenERP 6.1


OpenERP Partner form view

6
OpenERP 6.1 Import/Export

Column of CSV Field in OpenERP Constraints Possible values


id External id not shown in OpenERP
name Name of the partner Mandatory
ref Reference of the partner
customer Is the partner a customer? True / False or 1 / 0
supplier Is the partner a supplier? True / False or 1 / 0
category Category of partners External id! (see below)
lang Language of the partner (all the documents linked to the Special code! language.country (e.g. en_US,
partner will be printed in this language) en_GB, fr_FR, fr_BE, etc.)
website Website of the partner (2nd tab)
comment Notes about the partner (5th tab)
Next fields (starting with address/) can also be added by importing contacts (useful if you have many contacts for a unique partner)
address/name Contact Name
address/title/id Title of the contact base.res_partner_title_sir
Sir / Miss / Madam base.res_partner_title_miss
(titles can be added) base.res_partner_title_madam
address/function Function of the contact
address/type Address type Default / Invoice / Delivery / Contact / Other /
address/street Street
address/zip Zip
address/city City
address/country_id/id Country Special code! base.code of country (e.g.
base.be, base.fr, etc.)
address/phone Phone number
address/mobile Mobile number
address/fax Fax number
address/email E-mail address

Values underlined are the values by default (if nothing is defined in the .CSV file)

7
OpenERP 6.1 Import/Export

Categories of product
id External id not shown in OpenERP
name Name of the category Mandatory
parent_id/id Parent Category External id!

When importing partners (with contacts/addresses), two options are possible:


Anyway, if you have defined categories of partners, you have to start with the import of these categories.

if you have only one address/contact by partner: 1 file (all at once)


Import directly the address information in one csv file (using field starting with address/)

if you have many addresses/contacts by partner: 2 files (first partners, second contacts)
First, import the partners.
Then, using a second csv file, import addresses (see Mapping contacts in OpenERP 6.1)
To refer the partner to the contact, create a column (partner_id/id) for each contact with the name of the partner.

8
OpenERP 6.1 Import/Export

An example:
id name category supplier customer ref lang address/name address/title/id address/function address/type address/street address/zip address/city address/country_id/id address/phone
The Shelve House The Shelve House Consumers False True C01 en_US Nick Howson base.res_partner_title_sir Consultant delivery Rue de Bruxelles, 40 5000 Namur base.be 3281810562

9
OpenERP 6.1 Import/Export

Mapping contacts/addresses in OpenERP 6.1


OpenERP Contact/Address form view

10
OpenERP 6.1 Import/Export

Column of CSV Field in OpenERP Constraints Possible values


id External id not shown in OpenERP
name Name of the contact
partner_id/id Reference to the partner External id !
title/id Title of the contact base.res_partner_title_sir
Sir / Miss / Madam base.res_partner_title_miss
(titles can be added) base.res_partner_title_madam
function Function of the contact
type Address type Default / Invoice / Delivery / Contact / Other /
street Street
zip Zip
city City
country_id/id Country Special code! base.code country (e.g. base.be, base.fr, etc.)
phone Phone number
fax Fax number
mobile Mobile number
email E-mail address

11
OpenERP 6.1 Import/Export

An example:

id name partner_id/id title/id function type street zip city country_id/id phone fax mobile email
Nick Howson Nick Howson The Shelve House base.res_partner_title_sir Consultant delivery Rue de Bruxelles, 40 5000 Namur base.be 3281810562 81562635 474545498 nhowson@sheleve-house.com

12
OpenERP 6.1 Import/Export

Mapping products in OpenERP 6.1


OpenERP Product form view

13
OpenERP 6.1 Import/Export

Column of CSV Field in OpenERP Constraints Possible values


id External id not shown in OpenERP
name Name of the product Mandatory
default_code Reference of the product
sale_ok Defines if the product can be sold True / False or 1 / 0
purchase_ok Defines if the product can be purchased True / False or 1 / 0
description Product Description (4th tab)
type Type of product Consumable / Stockable Product / Service
procur_method Procurement Method of the product Make to Stock / Make to Order
supply_method Supply Method of the product Buy / Produce
standard_price Sale Price
cost_method Costing method Standard Price / Average Price
list_price Cost Price
categ_id/id Category of products External id! (see below)
uom_id/id Default Unit of Measure used for all stock operations product.product_uom_unit (= PCE)
product.product_uom_meter (= m)
etc.
uom_po_id/id Default Unit of Measure used for purchase orders As above
product_tmpl_id/id Mandatory! needed to import data! (can be
empty but a column has to be defined)
Values underlined are the values by default (if nothing is defined in the .CSV file)

Categories of product
id External id not shown in OpenERP
name Name of the category Mandatory
parent_id/id Parent Category External id!

If you have defined categories of products, you have to start with the import of these categories before the import of products.
Otherwise the column categ_id/id of products .CSV file will not be recognized!

14
OpenERP 6.1 Import/Export

An example:

id name categ_id/id procure_method cost_method supply_method standard_price list_price default_code type uom_po_id/id uom_id/id sale_ok purchase_ok
Shelf 200cm Shelf 200cm Marketable products Make to Order Standard Price Produce 80 210.0 SHE200 Stockable Product product.product_uom_unit product.product_uom_unit True True

15