I have a very simple scheduled action I’d like to implement
webhook_url = 'https://xxxxx'
recs = model.search([("x_studio_processed", "=", False)])
for rec in recs:
data = recs.x_studio_json_text # json_text is just a text field with json in it.
requests.post(webhook_url, data=data)
However I’m getting the following error, which didn’t happen in the automated action version of this script.
RPC_ERROR
Odoo Server Error
Traceback (most recent call last):
File "/home/odoo/src/odoo/odoo/tools/safe_eval.py", line 391, in safe_eval
return unsafe_eval(c, globals_dict, locals_dict)
File "ir.actions.server(1049,)", line 21, in <module>
NameError: name 'requests' is not defined
Is this a feature? Is there a workaround? I can think of one, but I’m new to Odoo and have no access to the code (I did mention this was Odoo online), and even this workaround is not guaranteed:
Basically, use the scheduled action to trigger an automated action (updating a field should do), and use the automated action script’s request object.
Any thoughts or ideas? I’m looking for simpler, Odoo-esque ways to handle this.
EDIT: I tweaked the description, because it turns out that both action types don’t have requests defined. I suspect that the requests that worked in an automated action were being done on an odoo.sh or homegrown odoo install.
So for Odoo online, even my workaround has failed. My next try (a true work around 🙂 ) is to use the external api to get these records, and then call whatever webservice I need.
5
As I can see on the error it says the requests library is not defined please make sure you import the library on the action you are using.
something like:
import requests
webhook_url = 'https://xxxxx'
...
3