我尝试开发一个连接到我的电子商务平台到Odoo的连接器。目前我有一个关于图像的问题。我的图像在mysql中的电子商务平台上,就像这样/catal/ image /toto.jpg
我想在odoo平台(产品)中插入这个图像,怎么做,只需在xml代码中插入这个:http://www.mydomain/catalog/image/toto.jpg?
谢谢。
发布于 2014-11-03 04:43:25
只是来自Odoo source code的评论
# Binary values may be byte strings (python 2.6 byte array), but
# the legacy OpenERP convention is to transfer and store binaries
# as base64-encoded strings. The base64 string may be provided as a
# unicode in some circumstances, hence the str() cast in symbol_f.
# This str coercion will only work for pure ASCII unicode strings,
# on purpose - non base64 data must be passed as a 8bit byte strings.因此您需要读取图像文件并将其编码为base64格式。并将结果传递给二进制域。
如果您的映像位于文件系统上,则如下所示:
import base64
img = open('path to my img', 'rb').read()
data = base64.b64encode(img)
# Write data to odoo您还可以使用openerp_proxy项目来简化与xml-rpc相关的工作。
https://stackoverflow.com/questions/26530375
复制相似问题