Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

1

POST to External URL from Server Action

By
Mick Radakovic
on 3/15/16, 1:19 PM 622 views

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?

1
Kazim Mirza
On 3/16/16, 12:27 AM

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

0
Jose Antonio
On 6/22/16, 5:14 AM

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

0
Damien Bouvy (dbo)
On 3/16/16, 5:29 PM

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

0
Diego Vázquez
On 3/16/16, 3:11 AM

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.


Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

2 follower(s)

Stats

Asked: 3/15/16, 1:19 PM
Seen: 622 times
Last updated: 6/22/16, 5:20 AM