Community mailing list archives
Re: SCRIPT TO IMPORT PRODUCT IMAGESby
How do you want to map the product to its picture? is it by name?
No, it's not that easy. You should use xmlrpc to upload the images (in python):
# remember to import base64
# read file data
sfile_data = sfile.read()
# do base64 encoding
product['image_variant'] = base64.b64encode(sfile_data)
# place in dict
template['image'] = product['image_variant']
# update the product
sock.execute(dbname, uid, pwd, 'product.product', 'write', productid, product)
If you still want to interact with the database and file system directly, then you should look at the ir.attachment model and ir_attachment table.
On Tue, Jul 12, 2016 at 10:16 AM, robert rottermann <email@example.com> wrote:
I assume, that all these samples from odoo 8 are no good, as with odoo 9 you do not store your files in the database anymore, but in the file system.
I am in the midst of creating scripts to transfer a largish non odoo erp site to odoo.
There are very few products (and no picture at all).
Nevertheless, I would like to try my hand in writing a script that does do bulk upload of images.
Please answer the following:
How do you want to map the product to its picture?
is it by name ?
Like "Product XX with red border" has a product_xx_with_red_border.jpg in the file system?
If you could provide some such mapping, the import could be easy (i hope).
On 12.07.2016 17:46, Matt Taylor wrote:
This post helped me do it with a python script:stackoverflow.com/a/16807529
On Tue, Jul 12, 2016 at 8:37 AM, Martin Malorni <firstname.lastname@example.org> wrote:
Here you go Peter.
From: Peter Mudoko <email@example.com>
Reply-To: "Odoo S.A. Community" <firstname.lastname@example.org>
Date: Tuesday, July 12, 2016 at 08:41
To: Community <email@example.com>
Subject: Re: SCRIPT TO IMPORT PRODUCT IMAGES
Thanks Stefan, i wanted a script to convert base 64 remember i have >10000 products...loop through all and convert to base 64 in orderly way for easy importation, or any idea how to go about will be appreciated.
On Tue, Jul 12, 2016 at 3:32 PM, Stefan Becker <firstname.lastname@example.org> wrote:
Images can be import trough csv by putting them as base64. Try to export a product with a image for a example. Am Dienstag, den 12.07.2016, 12:17 +0000 schrieb Peter Mudoko: > The products images are in excel so we are in the process of extracting images > to a central folder then import to odoo, can i get a script for any of the > scenario, if i get the script to extract image directly from excel it will be > excellent .