How to use xmlrpc to upload an image into the partner ?

Hi SME Odooer , the formal openerper , how is things ? Hope you are benefited from this powerful framework of Odoo , the formal OpenERP of Malaysia ,

today , i would like to share how to use xmlrpc to upload into partners ,
so the object to use are res.partner and ir.attachment ,

and you will need to use http://i-tools.org/base64 to upload some image and then click the
encode button


After you got the download file , copy the strings inside the file.

Here as usual, do your usual import
import xmlrpclib
          dbname  = 'somedb'
          usr = 'someusr'
          pwd ='somepass'
erp_client = xmlrpclib.ServerProxy('http://localhost:8069/xmlrpc/common')
uid = erp_client.login(dbname ,usr ,pwd)
erp_client = xmlrpclib.ServerProxy('http://localhost:8069/xmlrpc/object')
          base64str_file  = <use the copied strings , paste here !>
          partner_id = <code to get the partner id >
values = {'name':'some.jpg',
                        'type':'binary',
                        'res_id': partner_id  ,
                        'res_model':'res.partner',
                        'partner_id' : partner_id  ,
                        'datas' : base64str_file  }
new_id = erp_client.execute(dbname, uid, pwd, 'ir.attachment', 'create', values )
 
after executed , we should expect a new attachment at this selected Partner  !
Hope this help , till next update,cheers!