Hi,
I'm building a custom addon for Odoo and I'm wondering if it would be possible to get, within the controller, the informations of the current model.
For example, would it be possible to get the ID of the res.parner object I'm on ? I know how to get that information in the model but I can't figure it out how to get that in the controller.
Here is my code
@http.route('/myaddon/api-call', auth='user', csrf=False )
def calling(self, **kwargs):
theId = # How to get the ID of the res partner object I'm on ??
payload = { "Ctxt": "xxxxxxxxxxxxx",
"ID": theId,
}
req = urllib.request.Request(url='https://myapi', headers={
"Content-Type":"application/json"}, data = json.dumps(payload).encode())
reply = json.loads(urllib.request.urlopen(req).read().decode('UTF-8'))
if reply.get("error"):
print('Alert!!')
raise Exception(reply["error"])
return json.dumps(reply)
All the code works great except how to get that Id.
Do you know how to do it ?
Thanks !