【问题标题】:How to send to odoo an image of mysql to postgresql via xml rpc如何通过xml rpc将mysql的图像发送到odoo到postgresql
【发布时间】:2014-10-23 14:24:32
【问题描述】:

我尝试开发一个连接我的电子商务平台到 Odoo 的连接器。 目前我对图像有疑问。 我的图像在我的 mysql 内的电子商务平台上,就像这样 /catalog/image/toto.jpg

我想在odoo平台(产品)中插入这张图片,怎么做,只需在xml rpc代码中插入这个:http://www.mydomain/catalog/image/toto.jpg

谢谢。

【问题讨论】:

    标签: image web-services xml-rpc odoo


    【解决方案1】:

    来自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相关工作

    【讨论】:

    • 嗨,谢谢,但我的网络服务是 php 并使用 xml rpc。如何发送我的图片。
    猜你喜欢
    • 2012-02-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-01-13
    • 1970-01-01
    • 2019-06-01
    • 2020-04-16
    • 1970-01-01
    相关资源
    最近更新 更多