Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ

I import product image with zip and my image link is from google drive and I got this error. And image link is from another link, everything is working fine. How can I do that?My code is here 

if "http://" in image_path or "https://" in image_path:
_logger.info(image_path)
try:
link = \urllib.request.urlopen(image_path).read()
image_base64 = base64.encodestring(link)
if self.product_model == '1':
product_obj = self.env['product.template']
else:
product_obj = self.env['product.product']
product_id = product_obj.search([('name', '=', product)])
logging.info("Product++++++++++++++++++")
logging.info(product+'fdfdf')
logging.info(product_id)


vals = {
'image_1920': image_base64,
'name': product,
}
if self.pdt_operation == '1' and not product_id:
product_obj.create(vals)
elif self.pdt_operation == '1' and product_id:
product_id.write(vals)
elif self.pdt_operation == '2' and product_id:
product_id.write(vals)
elif not product_id and self.pdt_operation == '2':
raise Warning("Could not find the product '%s'" % product)
except Exception as e:
# raise Warning("Please provide correct URL for product '%s' or check your image size.!" % product)
raise Warning(e)

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
2
thg 7 21
2893
0
thg 3 15
3816
1
thg 7 23
2925
1
thg 1 23
2519
4
thg 3 22
17222