Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

1

How to add product image from xmlrpc call

By
jagdish
on 8/1/13, 9:31 AM 2,137 views

Hi,

I want insert image in product using xmlrpc, so how to pass data in php call to insert product image?? i have try to pass data like in point_of_sale_data.xml but it give me error cannot identify image file

Thanks jagdish

1
Alain Ivars
On 8/1/13, 12:22 PM
  • rename the image files according to your products (<product-code>.jpg or <id>.jpg)
  • Write a short python script which loops over the image files, encode with base64 and write to OpenERP with XMLRPC

# get file
yourImage = request.files.get('product1.jpg')
# read it
image = yourImage.file.read()
# encode it base64
imageBase64 = base64.b64encode(image)
# now pass it to your XMLRPC call

I hope that will help you :)

Thank Alain, for great answer. Can you please tell how to read image from xml rpc. I have created custom module in openerp v7 and I want to fetch value of that module in my website using django. I am able to fetch all text field, but not able to get image. While fetching image (binary field) it gives value probably b64encoded. I don't know to make that image visible without storing image data. Is there any direct way to access image url of openerp module. Can you please guide me ? Thanks for your time and help.

Vimal Rughani
on 3/18/14, 2:49 AM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 8/1/13, 9:31 AM
Seen: 2137 times
Last updated: 3/16/15, 8:10 AM