基本资料复制,OpenERP导入,导出问题
-
谢谢你,我试供应商列表了,导出没问题,但当导入新的数据库显示失败。
[color=red][size=8pt]导入失败:No such external ID currently defined in the system: export.res_partner_13_46, Traceback (most recent call last):
File "/usr/lib/pymodules/python2.7/openerp/addons/web/common/http.py", line 592, in send
result = openerp.netsvc.dispatch_rpc(service_name, method, args)
File "/usr/lib/pymodules/python2.7/openerp/netsvc.py", line 360, in dispatch_rpc
result = ExportService.getService(service_name).dispatch(method, params)
File "/usr/lib/pymodules/python2.7/openerp/service/web_services.py", line 572, in dispatch
res = fn(db, uid, *params)
File "/usr/lib/pymodules/python2.7/openerp/osv/osv.py", line 167, in execute_kw
return self.execute(db, uid, obj, method, *args, **kw or {})
File "/usr/lib/pymodules/python2.7/openerp/osv/osv.py", line 121, in wrapper
return f(self, dbname, *args, **kwargs)
File "/usr/lib/pymodules/python2.7/openerp/osv/osv.py", line 176, in execute
res = self.execute_cr(cr, uid, obj, method, *args, **kw)
File "/usr/lib/pymodules/python2.7/openerp/osv/osv.py", line 164, in execute_cr
return getattr(object, method)(cr, uid, *args, **kw)
File "/usr/lib/pymodules/python2.7/openerp/osv/orm.py", line 1412, in import_data
process_liness(self, datas, [], current_module, self._name, fields_def, position=position)
File "/usr/lib/pymodules/python2.7/openerp/osv/orm.py", line 1371, in process_liness
res = _get_id(relation, line[i], current_module, mode)
File "/usr/lib/pymodules/python2.7/openerp/osv/orm.py", line 1268, in _get_id
record_id = ir_model_data_obj._get_id(cr, uid, module, xml_id)
File "/usr/lib/pymodules/python2.7/openerp/tools/cache.py", line 18, in lookup
r = self.lookup(self2, cr, *args)
File "/usr/lib/pymodules/python2.7/openerp/tools/cache.py", line 46, in lookup
value = d[args] = self.method(self2, cr, *args)
File "/usr/lib/pymodules/python2.7/openerp/addons/base/ir/ir_model.py", line 640, in _get_id
raise ValueError('No such external ID currently defined in the system: %s.%s' % (module, xml_id))
ValueError: No such external ID currently defined in the system: export.res_partner_13_46[/size][/color]
是不是我选了不对的FIELD?请指点一二,谢谢。。。 -
这个错误是指引用到一个不存在的[b]外部标识[/b]。
想知道更多? [检测到链接无效,已移除] (设置->设置->External Identifiers)也就是XML ID,OpenERP里面所有的记录如果你想通过外部引用或者是导入导出就需要通过外部标识来关联,如果一个数据是从界面直接创建,创建后他的外部标识是没有记录的,但是当你将这个数据导出,就会自动创建一个外部标识与你导出的记录相关联,这个有什么好处呢?
1.你可以通过外部标识来关联系统原有数据,当你把导出的数据表其他数据修改后,只要外部标识这个没变化,导入后的数据机会根据外部标识来更新原有数据。
2.当这个外部标识不存在,OpenERP就会帮你创建一个新数据并自动关联到这个外部标识。
[b]注意[/b]:
当这个外部标识是一个many2one,或者是many2many字段的值的时候,如果不存在就会报错
以供应商这个对象来举个例子:
数据如下(可以直接保存为cvs格式):<br />"id","name","parent_id/id"<br />"__export__.res_partner_56","supplier_a","__export__.res_partner_55"<br />
导入到新数据库的时候__export__.res_partner_56这个外部标识虽然不存在,但是OpenERP会自动创建记录,但是__export__.res_partner_55这个id因为是引用,并不会自动创建,所以会报错。
[quote]
ValueError: No such external ID currently defined in the system: export.res_partner_55
[/quote]
解决的办法也很简单,只要在导入__export__.res_partner_56之前导入__export__.res_partner_55,即如下:<br />"id","name","parent_id/id"<br />"__export__.res_partner_55","supplier_a_father",<br />"__export__.res_partner_56","supplier_a","__export__.res_partner_55"<br />
希望能帮到你