minor fixes

This commit is contained in:
Subin Tom
2021-09-29 13:34:50 +05:30
parent d3bb920e71
commit 254b20bc09

View File

@@ -39,10 +39,10 @@ class TaxJarSettings(Document):
frappe.enqueue('erpnext.regional.united_states.setup.add_product_tax_categories', now=False) frappe.enqueue('erpnext.regional.united_states.setup.add_product_tax_categories', now=False)
elif fields_already_exist and fields_hidden: 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: else:
toggle_tax_category_fields('0') toggle_tax_category_fields(hidden='0')
@frappe.whitelist() @frappe.whitelist()
def update_nexus_list(self): def update_nexus_list(self):
@@ -55,9 +55,9 @@ class TaxJarSettings(Document):
self.set('nexus', new_nexus_list) self.set('nexus', new_nexus_list)
self.save() self.save()
def toggle_tax_category_fields(toggle): def toggle_tax_category_fields(hidden):
frappe.set_value('Custom Field',{'dt':'Sales Invoice Item', 'fieldname':'product_tax_category'},'hidden',toggle) 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',toggle) frappe.set_value('Custom Field',{'dt':'Item', 'fieldname':'product_tax_category'},'hidden',hidden)
def add_product_tax_categories(): def add_product_tax_categories():
@@ -67,14 +67,12 @@ def add_product_tax_categories():
def create_tax_categories(data): def create_tax_categories(data):
for d in data: for d in data:
tax_category = frappe.new_doc('Product Tax Category') if not frappe.db.exists('Product Tax Category',{'product_tax_code':d.get('product_tax_code')}):
tax_category.description = d.get("description") tax_category = frappe.new_doc('Product Tax Category')
tax_category.product_tax_code = d.get("product_tax_code") tax_category.description = d.get("description")
tax_category.category_name = d.get("name") tax_category.product_tax_code = d.get("product_tax_code")
try: tax_category.category_name = d.get("name")
tax_category.db_insert() tax_category.db_insert()
except frappe.DuplicateEntryError:
pass
def make_custom_fields(update=True): def make_custom_fields(update=True):
custom_fields = { custom_fields = {