From 47b8887ff5fd2904d542da8563dcbfb6bcf92dc3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Rahir?= Date: Wed, 18 Oct 2017 16:45:55 +0200 Subject: [PATCH] [FIX] iap_odoo: fix error general error raise Errors that are not whitelisted are not managed correctly due to the jsonrpc behaviour in Odoo. When we make a post in json using iap.jsonrpc function, it contacts iap.odoo.com. However, if this url does not respond, it falls back to the 'typo' page and the answer to the call has a '200' status code but with an 'error' key in its response. Currently, we manage the errors via whitelisting, which hides this kind of errors. We opted to raise this error (odoo server side) as a UserError and to add UserError to the whitelist. --- addons/iap/models/iap.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/addons/iap/models/iap.py b/addons/iap/models/iap.py index 659ea1974c5..37f760e385e 100644 --- a/addons/iap/models/iap.py +++ b/addons/iap/models/iap.py @@ -57,8 +57,10 @@ def jsonrpc(url, method='call', params=None): e_class = InsufficientCreditError elif name == 'AccessError': e_class = exceptions.AccessError - else: + elif name == 'UserError': e_class = exceptions.UserError + else: + raise requests.exceptions.ConnectionError() e = e_class(message) e.data = response['error']['data'] raise e