Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
5 Odpowiedzi
11030 Widoki

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?

Awatar
Odrzuć
Najlepsza odpowiedź

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

Awatar
Odrzuć
Najlepsza odpowiedź

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!

Awatar
Odrzuć
Najlepsza odpowiedź

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

Awatar
Odrzuć
Najlepsza odpowiedź

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

Awatar
Odrzuć
Najlepsza odpowiedź

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.


Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
4
sie 25
22057
0
sty 21
3760
1
maj 25
798
0
lis 24
1442
0
mar 24
1423