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

I am using odoo v12 I have to try to simple request to get any simple URL using request class but not retrieve any result such as I using.

import requests

r = requests.get("https://itstrianglemobile.com/images/phones/iphone-xr/iPhone-xr-1.jpg") 

when I execute that code using odoo it is not working. but when I try to execute using terminal it is working. I have no idea about that.

Аватар
Отменить

Are you getting any error message? or what is the response you are getting

Автор

No, I am not getting an error message from that but using terminal it gives me a status code as 200 and also url content.

We have tried the same over here, from the Odoo as well as terminal and seems fine. So the execution stops on this call? or rest of the code after this call is not getting executed?

Автор

I also check the same thing with the other odoo v12 server and it working perfectly but my actual server it is not working I have no idea that why odoo behavior like this. I also check the request version for my local and my actual server is same.

Лучший ответ
Odoo 13 default core module example requests.get image.
Example: requests.get URL https://www.google.com/s2/favicons?sz=64&domain_url=yahoo.com

File: odoo13/addons/link_tracker/models/link_tracker.py

favicon = fields.Char(string='Favicon', compute='_compute_favicon', store=True)

@api.depends('url')
def _compute_favicon(self):
for tracker in self:
try:
icon = requests.get('http://www.google.com/s2/favicons', params={'domain': tracker.url}, timeout=5).content
icon_base64 = base64.b64encode(icon).replace(b"\n", b"").decode('ascii')
except:
icon_base64 = 'iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8'
tracker.favicon = icon_base64


Аватар
Отменить
Лучший ответ

I am having a problem with this.. is there any solution now? im using v13

Аватар
Отменить
Related Posts Ответы Просмотры Активность
0
авг. 20
4696
1
июн. 24
2081
4
мая 24
7780
1
июл. 23
2655
3
июн. 23
3667