From 313d3249e6568e091e628107f19e7400c0f92880 Mon Sep 17 00:00:00 2001 From: Ivan Yelizariev Date: Tue, 10 Mar 2020 16:16:05 +0500 Subject: [PATCH] :shield: treat simplejson as external package that may not be installed --- .isort.cfg | 2 +- mailgun/models/ir_config_parameter.py | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/.isort.cfg b/.isort.cfg index b64cbab..46da8fa 100644 --- a/.isort.cfg +++ b/.isort.cfg @@ -9,4 +9,4 @@ line_length=88 known_odoo=odoo known_odoo_addons=odoo.addons sections=FUTURE,STDLIB,THIRDPARTY,ODOO,ODOO_ADDONS,FIRSTPARTY,LOCALFOLDER -known_third_party=requests,simplejson,werkzeug +known_third_party=requests,werkzeug diff --git a/mailgun/models/ir_config_parameter.py b/mailgun/models/ir_config_parameter.py index 57d7eac..e318dd8 100644 --- a/mailgun/models/ir_config_parameter.py +++ b/mailgun/models/ir_config_parameter.py @@ -1,10 +1,15 @@ import logging import requests -import simplejson from odoo import api, models +try: + import simplejson as json +except ImportError: + import json + + _logger = logging.getLogger(__name__) @@ -23,6 +28,6 @@ class IrConfigParameter(models.Model): res = requests.put(url, auth=("api", api_key)) if ( res.status_code == 200 - and simplejson.loads(res.text)["domain"]["state"] == "active" + and json.loads(res.text)["domain"]["state"] == "active" ): self.sudo().set_param("mailgun.verified", "1")