Merge pull request #22863 from deepeshgarg007/taxjar_fix

fix: Import pycountry and taxjar only if taxjar is enabled
This commit is contained in:
Deepesh Garg 2020-08-01 13:52:40 +05:30 committed by GitHub
commit 946e106714
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,8 +1,5 @@
import traceback import traceback
import pycountry
import taxjar
import frappe import frappe
from erpnext import get_default_company from erpnext import get_default_company
from frappe import _ from frappe import _
@ -32,6 +29,7 @@ def get_client():
def create_transaction(doc, method): def create_transaction(doc, method):
import taxjar
"""Create an order transaction in TaxJar""" """Create an order transaction in TaxJar"""
if not TAXJAR_CREATE_TRANSACTIONS: if not TAXJAR_CREATE_TRANSACTIONS:
@ -208,6 +206,7 @@ def get_shipping_address_details(doc):
def get_iso_3166_2_state_code(address): def get_iso_3166_2_state_code(address):
import pycountry
country_code = frappe.db.get_value("Country", address.get("country"), "code") country_code = frappe.db.get_value("Country", address.get("country"), "code")
error_message = _("""{0} is not a valid state! Check for typos or enter the ISO code for your state.""").format(address.get("state")) error_message = _("""{0} is not a valid state! Check for typos or enter the ISO code for your state.""").format(address.get("state"))