Odoo Help


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.


How to import images for products in binary to the database?

Julián Lozano
on 2/15/13, 5:35 PM 12,145 views

I'd like to know how to do batch import of images for the products and if its better import products first and then the products images or both at the same time.

I am most interested in the straigh forward way. How is this?

on 3/27/13, 4:00 PM

I would first import the products (e.g. with the Import-Wizard) and afterwards I would import the product images. My tip to batch import images: rename the image files according to your products (.jpg or .jpg) Write a short python script which loops over the image files, encode with base64 and write to OpenERP with XMLRPC

Andreas Brueckl
on 2/22/13, 4:43 AM

Marc Cassuto

--Marc Cassuto--
| 4 4 8
Montreal, Canada
--Marc Cassuto--

Marc Cassuto
On 8/2/13, 5:43 PM

Here the complete procedure for Linux users :

1/ import all your products

2/ export your products : this step is mandatory to get the external ID of your product. In my case I exported Name (that is mandatory) and ean13 since the picture's filename was name as follow :


3/ open your exported file (product.product.csv) with libreoffice and save it again with option "edit filter settings" in order to change the CSV separator to whatever else than ",". This is a little trick to avoid complicated script to deal with record that embed a coma.

4/ use the following script :

    # Usage : MakeBase64CSV.sh infile.csv outfile.csv
    # infile.csv columns are : externalID, name, filename or identifier
    # infile.csv separator MUST BE |

echo \"External ID\",\"Name\",\"image\" > $2

while IFS="|" read f1 f2 f3; do

    # recopy external ID and name
    echo -n $f1,\"$f2\", >> $2

    #If third column represents the picture's filename (not the key), please use this command
    #cat $(echo ${f3} | tr -d '\r' | tr -d '"') | base64 --wrap=0 >> $2

    #If third column represents the key to match with the filename, please use this command
    cat $(echo ${f3} | tr -d '\r' | tr -d '"').jpg | base64 --wrap=0 >> $2

    #Carrier return at end of line
    echo  >> $2
done < $1

5/ then use your script

./MakeBase64CSV.sh product.product.csv out.csv

In my example, all the pictures are in the same directory.

6/ you can now import your file out.csv into openERP. (Don't forget to change the CSV separator).

7/ If you run into the following error :

field larger than field limit (131072)

Please do the following :

  • modify the file addons/base_import/models.py
  • add the following line at the very begining of the _convert_import_data function :


  • delete the file addons/base_import/models.pyc

  • restart your server
  • redo the import of your out.csv file

hi Marc, would you mind to correct the line that has been identified as faulty (if the complaint is correct)?

on 6/2/14, 7:15 PM
Bart Criel
On 2/13/14, 10:07 AM

I encountered a few problems when using Marc's steps, but I sorted it out.

  1. The one but last line in the bash script needs to be echo \" >> $2, and not echo >> $2
  2. I ran into the field limit, mentioned in step 7. Adding the line csv.field_size_limit(2097152) did not help. Instead, I added the line at the very top of the function _read_csv in models.py

After making these changes, I was able to generate an import file, and to import pictures to my products.


Hi Bart, you solved it? I did the script but when i try to import "out.cvs" on "odoo import page", the system doesn't recognice the file. Would you explain me how you did? At least until you gave the error... Thanks

Nicolás Visús
on 8/22/14, 12:05 AM
Cyrus Waithaka
On 4/4/16, 7:08 PM

I have uploaded a module on odoo apps that can help achieve this need.  https://apps.odoo.com/apps/modules/9.0/product_image_from_url/ 

My module employs the concept of importing the images as URLs using a normal csv/ excel import file. You can then download the images from the imported URLs in batch. I hope this will help.

Nicolás Visús
On 8/22/14, 12:03 AM

Is need to put the line csv.field_size_limit(2097152) (or a bigger number. Depends of image size) in lines 230 and 271, next to "_read_csv" and "convert_import_data" lines into addons/base_import/models.py file.

Then follow the instructions above.


Your file should have the extension csv NOT cvs!

AD LIBITOM, michel Guénard
on 8/22/14, 3:25 AM

Yes. Mi file ("out.csv") have a CSV extension. My mistake was in having skipped the step of modifying "csv.field_size_limit (2097152)". Now it works! Thanks for your answer

Nicolás Visús
on 8/22/14, 12:56 PM
Nicolás Visús
On 9/3/14, 1:19 AM

Is need to put the line csv.field_size_limit(2097152) (or a bigger number) in lines 230 and 271, next to "_read_csv" and "convert_import_data" lines into addons/base_import/models.py file.

Then follow the instructions above.

Thomas Walter
On 5/26/14, 6:04 PM

Dear all,

thanks for this post. I managed to create an upload file for my pictures.

Unfortunately i run into the "field larger than field limit" error. I tried to add the "csv.field_size_limit(2097152)" into the model.py file, deleted the models.pyc file and restarted the server.

However no matter where i put the csv.field_size_limit statement the openerp either does not work or shows the same failure.

Could you please post specify more precisly where i have to put the csv.field_size_limit?

thanks, Thomas

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

7 follower(s)


Asked: 2/15/13, 5:35 PM
Seen: 12145 times
Last updated: 4/4/16, 7:08 PM