Skip to Content
Menu
This question has been flagged
5 Replies
11011 Zobrazenia

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?

Avatar
Zrušiť
Best Answer

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

Avatar
Zrušiť
Best Answer

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!

Avatar
Zrušiť
Best Answer

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??

Avatar
Zrušiť
Best Answer

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...

Avatar
Zrušiť
Best Answer

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.


Avatar
Zrušiť
Related Posts Replies Zobrazenia Aktivita
4
aug 25
22053
0
jan 21
3749
1
máj 25
789
0
nov 24
1440
0
mar 24
1418