From 07a937ea1b474736a6709cc299794be942974145 Mon Sep 17 00:00:00 2001 From: Ivan Yelizariev Date: Tue, 10 Mar 2020 16:16:05 +0500 Subject: [PATCH 1/2] :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 466932b..caad3a6 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 +known_third_party=requests 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") From 6d5d5d494ce784845f4417f7b5d2d975a858389d Mon Sep 17 00:00:00 2001 From: Ivan Yelizariev Date: Wed, 11 Mar 2020 16:00:08 +0500 Subject: [PATCH 2/2] :shield: avoid adding partners without emails to subscription otherwise it shows "Please complete information" popup which is not supposed to be raised in the test tour --- mail_private/tests/test_js.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mail_private/tests/test_js.py b/mail_private/tests/test_js.py index 1bee5dc..d170c5e 100644 --- a/mail_private/tests/test_js.py +++ b/mail_private/tests/test_js.py @@ -22,7 +22,9 @@ class TestUi(odoo.tests.HttpCase): env = Environment(self.registry.test_cr, self.uid, {}) partners = env["res.partner"].search([]) - new_follower = env["res.partner"].search([("name", "ilike", "Ja")]) + new_follower = env["res.partner"].search( + [("name", "ilike", "Ja"), ("email", "!=", False)] + ) for partner in partners: partner.message_subscribe(new_follower.ids, [])