Community mailing list archives

community@mail.odoo.com

Re: SCRIPT TO IMPORT PRODUCT IMAGES

by
Matt Taylor
- 07/12/2016 15:24:06
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.

Matt



On Tue, Jul 12, 2016 at 10:16 AM, robert rottermann <robert@redcor.ch> 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).

robert





On 12.07.2016 17:46, Matt Taylor wrote:
This post helped me do it with a python script:

stackoverflow.com/a/16807529

Matt


On Tue, Jul 12, 2016 at 8:37 AM, Martin Malorni <mm@microcom.ca> wrote:

Here you go Peter.

Martin Malorni

From: Peter Mudoko <petypi@gmail.com>
Reply-To: "Odoo S.A. Community" <community@mail.odoo.com>
Date: Tuesday, July 12, 2016 at 08:41
To: Community <community@mail.odoo.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.


Systems developer

Laballieds,

Nairobi:gate 256, Nairobi.

P.O.Box - 45855 -00100, Nairobi.

Tel:+254 721449067

Email petypi@gmail.com

Mobile: +254 721449067

Website www.softlinkoptions.com


On Tue, Jul 12, 2016 at 3:32 PM, Stefan Becker <ich@funbaker.de> 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 .

_______________________________________________
Mailing-List: https://www.odoo.com/groups/community-59
Post to: mailto:community@mail.odoo.com
Unsubscribe: https://www.odoo.com/groups?unsubscribe


_______________________________________________
Mailing-List: https://www.odoo.com/groups/community-59
Post to: mailto:community@mail.odoo.com
Unsubscribe: https://www.odoo.com/groups?unsubscribe

_______________________________________________
Mailing-List: https://www.odoo.com/groups/community-59
Post to: mailto:community@mail.odoo.com
Unsubscribe: https://www.odoo.com/groups?unsubscribe


_______________________________________________
Mailing-List: https://www.odoo.com/groups/community-59
Post to: mailto:community@mail.odoo.com
Unsubscribe: https://www.odoo.com/groups?unsubscribe


_______________________________________________
Mailing-List: https://www.odoo.com/groups/community-59
Post to: mailto:community@mail.odoo.com
Unsubscribe: https://www.odoo.com/groups?unsubscribe