- Write a short python script which loops over the image files, encode with base64 and write to OpenERP with XMLRPC
1 产品图片是需要转为 base64编码的
2:如果需要批量导入,可以吧图片名字和 产品编码关联,然后代码批量写入即可以
下面是一个写入产品图片的例子,最好由xmlrpc方法写入,直接写入数据库,不会触发中图和小图的计算
=================
- #!/usr/bin/env python
# -*- coding: utf-8 -*-import psycopg2
import sys
import base64
import oerpliboerp = oerplib.OERP(‘localhost‘, protocol=‘xmlrpc‘, port=8069)
oerp.login(‘user‘, ‘passwprd‘, ‘dbname‘)
pp = oerp.get(‘product.product‘)picture_file=‘/tmp/yks_logo.png‘
product_id=113
f = open(picture_file, ‘rb‘)
binary = f.read()
image = base64.encodestring(binary)pp.write(product_id, {‘image‘: image} )
openerp 产品图片的批量写入,布布扣,bubuko.com
时间: 2024-10-28 14:17:28