我正在开发一个将数据从Open ERP迁移到Xero的项目。我被困在移动附件上。我使用的是Python lib oerplib 0.8.3。我找不到下载附件的方法,或者有办法将它们从Open ERP直接移到Xero。 使用通常的oerplib方法,我设法获得了一些关于附件的数据:
attachment_obj = oerp.get('ir.attachment')
attachment_ids = attachment_obj.search([])
示例数据:
{
"create_date": "2013-10-09 08:35:07",
"file_type": "application/vnd.oasis.opendocument.spreadsheet",
"res_model": "project.task",
"write_uid": 4,
"res_name": "Map Categories",
"db_datas": "False",
"file_size": "27278",
"partner_id": 44,
"id": "111",
"create_uid": 4,
"user_id": 4,
"company_id": 1,
"parent_id": "False",
"index_content": "",
"type": "binary",
"store_fname": "5a2/5a264e792eaa5305879a89e7ce2cbb6bd0099fcd",
"description": "False",
"write_date": "2013-10-09 08:35:07",
"name": "Codes(1).ods",
"url": "False",
"res_id": "44",
"datas": "",
"datas_fname": "Codes(1).ods"
}
非常感谢任何帮助。
答案 0 :(得分:0)
在深入了解Open ERP文档后,我发现附件在DB中保存为base64编码的字符串,除非设置了文档插件。因此,对于任何可能发现自己被困的人,只需从附件资源对象的datas
属性中读取数据
attachment_obj = oerp.browse('ir.attachment', 17)
attachment_data = attachment_obj.datas