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

I'd like to post the request to an external URL once the product is updated in Odoo, but when I tried to do that in the Server Action I got the errors saying that I'm not allowed to import urllib3 in the Python code there. 
What is my alternative?

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

Hi Mick

Hope you are good..

Its seems you have used urllib3 but you didn't install urllib3

To install this use "sudo pip install urllib3" And then restart the server it will work after that.

Hope, this answer will help you.

Please don't hesitate to ask any question regarding this.

Thank You

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

Hello @Damien, sorry what do you mean with creating the action in a separated .py file? where can I create such file and what context will I have within the code? can you reference some literature on how to create a server action within a py file?

Thanks!

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

Hello.

I also need to do the same, make a POST request after a create or update a user, but when I try to use the request as Diego suggested, I get the error 

ValueError: "name 'requests' is not defined" while evaluating

Maybe I'm doing something wrong??

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

Hi,

Keep in mind that server actions are safe_eval and most python libraries, even if installed in your system, are not available in them (except for time, datetime and dateutil). If you have the opportunity to do this in a .py file, I would strongly advise you to do so and then call this function from the server action... Otherwise, you're going to have to build a lot of things from the ground up...

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

Hello Mick,

other possibility is trying to do with requests lib (that is powered by urlib3): 

http://docs.python-requests.org/en/master/

I use this and works perfectly,

best regards.


Аватар
Отменить
Related Posts Ответы Просмотры Активность
4
авг. 25
22053
0
янв. 21
3749
1
мая 25
789
0
нояб. 24
1440
0
мар. 24
1418