OpenERP 7.0 导入 (在导入最下面的一个问题里)

本文介绍如何在 OpenERP 7.0 中导入外部数据,包括使用 ExternalID 和 DatabaseID 进行记录关联的方法,解决 CSV 文件格式问题,处理多对多及一对多字段的导入技巧等。

OpenERP 7.0 导入 (在导入最下面的一个问题里)

没想到是这样导入关联数据。External ID,Related (postgresql table name)/External ID 

这样方便多了


Frequently Asked Questions Need to import data from an other application?

In order to re-create relationships between different records, you should use the unique identifier from the original application and map it to the ID column in OpenERP. When you import an other record that links to the first one, use XXX/ID to the original unique identifier.

The ID will 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 "Tools" 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 mechanism 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 should use one of these 3 ways to reference records in relations. Here is when you should 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 should 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 many2many relationship field (e.g. a customer that has multiple tags)?

The tags should 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 one2many 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 customers 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 for).

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 for. (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 orignial 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.


这是一个基于AI视觉识别与3D引擎技术打造的沉浸式交互圣诞装置。 简单来说,它是一棵通过网页浏览器运行的数字智慧圣诞树,你可以用真实的肢体动作来操控它的形态,并将自己的回忆照片融入其中。 1. 核心技术组成 这个作品是由三个尖端技术模块组成的: Three.js 3D引擎:负责渲染整棵圣诞树、动态落雪、五彩挂灯和树顶星。它创建了一个具备光影和深度感的虚拟3D空间。 MediaPipe AI手势识别:调用电脑摄像头,实时识别手部的21个关键点。它能读懂你的手势,如握拳、张开或捏合。 GSAP动画系统:负责处理粒子散开与聚合时的平滑过渡,让成百上千个物体在运动时保持顺滑。 2. 它的主要作用与功能 交互式情感表达: 回忆挂载:你可以上传本地照片,这些照片会像装饰品一样挂在树上,或者像星云一样环绕在树周围。 魔法操控:握拳时粒子迅速聚拢,构成一棵挺拔的圣诞树;张开手掌时,树会瞬间炸裂成星光和雪花,照片随之起舞;捏合手指时视线会拉近,让你特写观察某一张选中的照片。 节日氛围装饰: 在白色背景下,这棵树呈现出一种现代艺术感。600片雪花在3D空间缓缓飘落,提供视觉深度。树上的彩色粒子和白色星灯会周期性地呼吸闪烁,模拟真实灯串的效果。 3. 如何使用 启动:运行代码后,允许浏览器开启摄像头。 装扮:点击上传照片按钮,选择温馨合照。 互动:对着摄像头挥动手掌可以旋转圣诞树;五指张开让照片和树化作满天星辰;攥紧拳头让它们重新变回挺拔的树。 4. 适用场景 个人纪念:作为一个独特的数字相册,在节日陪伴自己。 浪漫惊喜:录制一段操作手势让照片绽放的视频发给朋友。 技术展示:作为WebGL与AI结合的案例,展示前端开发的潜力。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值