zoukankan      html  css  js  c++  java
  • openerp 产品图片的批量写入

    • 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 oerplib

      oerp = 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} )

  • 相关阅读:
    html5 to jsp
    java通过springMail发送邮件
    solr配置-Solrconfig.xml
    solr配置-Schema.xml
    solr连接数据库导入数据
    log4j 1.2 配置总结
    1-12 ARP协议
    1-11 ICMP协议
    1-10 网际层
    1-9 TCP/IP参考模型
  • 原文地址:https://www.cnblogs.com/alangwansui/p/3920336.html
Copyright © 2011-2022 走看看