minor fixes
diff --git a/erpnext/erpnext_integrations/doctype/taxjar_settings/taxjar_settings.py b/erpnext/erpnext_integrations/doctype/taxjar_settings/taxjar_settings.py
index e03a2ac..725a61a 100644
--- a/erpnext/erpnext_integrations/doctype/taxjar_settings/taxjar_settings.py
+++ b/erpnext/erpnext_integrations/doctype/taxjar_settings/taxjar_settings.py
@@ -39,10 +39,10 @@
frappe.enqueue('erpnext.regional.united_states.setup.add_product_tax_categories', now=False)
elif fields_already_exist and fields_hidden:
- toggle_tax_category_fields('1')
+ toggle_tax_category_fields(hidden='1')
- elif not TAXJAR_CREATE_TRANSACTIONS and not TAXJAR_CALCULATE_TAX and not TAXJAR_SANDBOX_MODE:
- toggle_tax_category_fields('0')
+ else:
+ toggle_tax_category_fields(hidden='0')
@frappe.whitelist()
def update_nexus_list(self):
@@ -55,9 +55,9 @@
self.set('nexus', new_nexus_list)
self.save()
-def toggle_tax_category_fields(toggle):
- frappe.set_value('Custom Field',{'dt':'Sales Invoice Item', 'fieldname':'product_tax_category'},'hidden',toggle)
- frappe.set_value('Custom Field',{'dt':'Item', 'fieldname':'product_tax_category'},'hidden',toggle)
+def toggle_tax_category_fields(hidden):
+ frappe.set_value('Custom Field',{'dt':'Sales Invoice Item', 'fieldname':'product_tax_category'},'hidden',hidden)
+ frappe.set_value('Custom Field',{'dt':'Item', 'fieldname':'product_tax_category'},'hidden',hidden)
def add_product_tax_categories():
@@ -67,14 +67,12 @@
def create_tax_categories(data):
for d in data:
- tax_category = frappe.new_doc('Product Tax Category')
- tax_category.description = d.get("description")
- tax_category.product_tax_code = d.get("product_tax_code")
- tax_category.category_name = d.get("name")
- try:
+ if not frappe.db.exists('Product Tax Category',{'product_tax_code':d.get('product_tax_code')}):
+ tax_category = frappe.new_doc('Product Tax Category')
+ tax_category.description = d.get("description")
+ tax_category.product_tax_code = d.get("product_tax_code")
+ tax_category.category_name = d.get("name")
tax_category.db_insert()
- except frappe.DuplicateEntryError:
- pass
def make_custom_fields(update=True):
custom_fields = {