From 57a7eb5b9bea1e2b038c955a658b4e3318ad8b86 Mon Sep 17 00:00:00 2001
From: Daniel Libonati
Date: Thu, 2 Jan 2020 12:36:07 -0300
Subject: [PATCH] [FIX] Use resp.get() to prevent KeyError
Whenever a JSON RPC call returns `None`, the `result` key in the response will not exist, and therefore it will trigger a KeyError. By using get(), None is returned if the the 'result' key does not exist.
Fixes #8
---
odooly.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/odooly.py b/odooly.py
index e3e345e..346d676 100644
--- a/odooly.py
+++ b/odooly.py
@@ -383,7 +383,7 @@ def dispatch_jsonrpc(url, service_name, method, args):
resp = http_post(url, json.dumps(data).encode('ascii'))
if resp.get('error'):
raise ServerError(resp['error'])
- return resp['result']
+ return resp.get('result')
class partial(functools.partial):