Zum Inhalt springen
Menü
Sie müssen registriert sein, um mit der Community zu interagieren.
Diese Frage wurde gekennzeichnet

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)

Avatar
Verwerfen
Verknüpfte Beiträge Antworten Ansichten Aktivität
2
Juli 21
2911
0
März 15
3851
1
Juli 23
2939
1
Jan. 23
2566
4
März 22
17256