Перейти к содержимому
Меню
Чтобы взаимодействовать с сообществом, необходимо зарегистрироваться.
Этот вопрос был отмечен
4493 Представления

Hello,

I'm using product_images_olbs, it's working well. I'm trying to modify the code so I save the image uploaded with a different name in a file, but it doesn't work! Here's my code:

 def get_image(self, cr, uid, id):
    each = self.read(cr, uid, id, ['link', 'filename', 'image'])
    if each['link']:
        try:
            (filename, header) = urllib.urlretrieve(each['filename'])

            f = open(filename , 'rb')
            data=f.read()
            img = base64.encodestring(data)
            f.close()
            with open('test.jpg','wb') as f2:
               f2.write(data)

            f2.close()  


        except:
            img = ''
    else:
        img = each['image']

    return img

This code works when it's launched outside openerp!

Can someone help me figure out why the file test.jpg is not created?

Аватар
Отменить
Related Posts Ответы Просмотры Активность
1
мар. 15
4655
1
июл. 25
2032
0
апр. 22
2302
1
мая 20
3417
0
мар. 20
3432