In Odoo14, I have set up a cronjob that calls a method below:
from odoo.addons.web.controllers.main import Export
def get_export_fields_data(self):
export_fields = Export().namelist(self.model, self.export_id.id)
return export_fields
When I try to run the cronjob manually, this works fine and returns the required data.
But, when the cronjob is automatically executed in the specified time, this code does not work and throws an error as below:
File "/home/odoo14/envodoo14/lib/python3.10/site-packages/werkzeug/local.py", line 447, in__get__obj= instance._get_current_object()
File "/home/odoo14/envodoo14/lib/python3.10/site-packages/werkzeug/local.py", line 569, in _get_current_objectreturnself.__local() # type: ignore
File "/home/odoo14/envodoo14/lib/python3.10/site-packages/werkzeug/local.py", line 234, in _lookup
raise RuntimeError("object unbound")
RuntimeError: object unbound
While I debugged the issue, I found out that there is an error while accessing odoo.http.request in the odoo/addons/web/controllers/main.py file. There is some difference between request while running the cronjob manually versus executing automatically.
Has anyone faced this error?