Odoo Help

1

POST to External URL from Server Action

By
Mick Radakovic
on 3/15/16, 1:19 PM 1,130 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)

--Damien Bouvy (dbo)--
2010
| 1 0 1
Grand-Rosière, Belgium
--Damien Bouvy (dbo)--

Damien is a core developer part of Odoo's R&D department. He has developed numerous features on Odoo, including: the subscription application, the billing processes of Odoo Online, refactoring of quotation templates, payment acquirers, etc.

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.


About This Community

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

Register

Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

2 follower(s)

Stats

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