From 1126a43979a35c91e1c9f3af3b928c5a7121ad26 Mon Sep 17 00:00:00 2001 From: Prateeksha Singh Date: Mon, 11 Dec 2017 23:22:30 +0530 Subject: [PATCH] [fix] hub connection, fixes #11357 --- erpnext/hub_node/__init__.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/erpnext/hub_node/__init__.py b/erpnext/hub_node/__init__.py index 76a7f6fb27d..8eb10747fd1 100644 --- a/erpnext/hub_node/__init__.py +++ b/erpnext/hub_node/__init__.py @@ -16,7 +16,7 @@ def enable_hub(): @frappe.whitelist() def get_items(start=0, limit=20, category=None, order_by=None, company=None, text=None): - connection = get_connection() + connection = get_client_connection() filters = { 'hub_category': category, } @@ -32,7 +32,7 @@ def get_items(start=0, limit=20, category=None, order_by=None, company=None, tex @frappe.whitelist() def get_categories(): - connection = get_connection() + connection = get_client_connection() response = connection.get_list('Hub Category') return response @@ -40,20 +40,24 @@ def get_categories(): def get_item_details(hub_sync_id=None): if not hub_sync_id: return - connection = get_connection() + connection = get_client_connection() return connection.get_doc('Hub Item', hub_sync_id) @frappe.whitelist() def get_company_details(hub_sync_id): - connection = get_connection() + connection = get_client_connection() return connection.get_doc('Hub Company', hub_sync_id) -def get_connection(): +def get_client_connection(): + # frappeclient connection + hub_connection = get_hub_connection() + return hub_connection.connection + +def get_hub_connection(): hub_connector = frappe.get_doc( 'Data Migration Connector', 'Hub Connector') hub_connection = hub_connector.get_connection() - # frappeclient connection - return hub_connection.connection + return hub_connection def make_opportunity(buyer_name, email_id): buyer_name = "HUB-" + buyer_name @@ -174,7 +178,7 @@ def send_opportunity(contact): user=contact.email_id )) - connection = get_connection() + connection = get_hub_connection() response = connection.insert('Hub Message', args) return response.ok