fix: Ignore validations for Tax Setup
diff --git a/erpnext/regional/india/setup.py b/erpnext/regional/india/setup.py
index 31e936d..c554630 100644
--- a/erpnext/regional/india/setup.py
+++ b/erpnext/regional/india/setup.py
@@ -25,6 +25,7 @@
frappe.enqueue('erpnext.regional.india.setup.add_hsn_sac_codes', now=frappe.flags.in_test)
create_gratuity_rule()
add_print_formats()
+ update_accounts_settings_for_taxes()
def add_hsn_sac_codes():
if frappe.flags.in_test and frappe.flags.created_hsn_codes:
@@ -733,6 +734,7 @@
for d in docs:
if not frappe.db.exists("Tax Withholding Category", d.get("name")):
doc = frappe.get_doc(d)
+ doc.flags.ignore_validate = True
doc.flags.ignore_permissions = True
doc.flags.ignore_mandatory = True
doc.insert()
@@ -749,11 +751,12 @@
doc.append("rates", d.get('rates')[0])
doc.flags.ignore_permissions = True
+ doc.flags.ignore_validdate = True
doc.flags.ignore_mandatory = True
+ doc.flags.ignore_links = True
doc.save()
def set_tds_account(docs, company):
- abbr = frappe.get_value("Company", company, "abbr")
parent_account = frappe.db.get_value("Account", filters = {"account_name": "Duties and Taxes", "company": company})
if parent_account:
docs.extend([
@@ -912,7 +915,6 @@
]
def create_gratuity_rule():
-
# Standard Indain Gratuity Rule
if not frappe.db.exists("Gratuity Rule", "Indian Standard Gratuity Rule"):
rule = frappe.new_doc("Gratuity Rule")
@@ -930,3 +932,7 @@
rule.flags.ignore_mandatory = True
rule.save()
+
+def update_accounts_settings_for_taxes():
+ if frappe.db.count('Company') == 1:
+ frappe.db.set_value('Accounts Settings', None, "add_taxes_from_item_tax_template", 0)
\ No newline at end of file
diff --git a/erpnext/setup/doctype/company/company.py b/erpnext/setup/doctype/company/company.py
index 8fd905d..8fc0cbe 100644
--- a/erpnext/setup/doctype/company/company.py
+++ b/erpnext/setup/doctype/company/company.py
@@ -110,7 +110,7 @@
self.create_default_warehouses()
if frappe.flags.country_change:
- install_country_fixtures(self.name)
+ install_country_fixtures(self.name, self.country)
self.create_default_tax_template()
if not frappe.db.get_value("Department", {"company": self.name}):
diff --git a/erpnext/setup/setup_wizard/operations/taxes_setup.py b/erpnext/setup/setup_wizard/operations/taxes_setup.py
index 59f1e58..6da3f38 100644
--- a/erpnext/setup/setup_wizard/operations/taxes_setup.py
+++ b/erpnext/setup/setup_wizard/operations/taxes_setup.py
@@ -129,8 +129,11 @@
if fieldname not in tax_row:
tax_row[fieldname] = default_value
- return frappe.get_doc(template).insert(ignore_permissions=True)
-
+ doc = frappe.get_doc(template)
+ doc.flags.ignore_links = True
+ doc.flags.ignore_validate = True
+ doc.insert(ignore_permissions=True)
+ return doc
def make_item_tax_template(company_name, template):
"""Create an Item Tax Template.
@@ -155,14 +158,21 @@
if 'tax_rate' not in tax_row:
tax_row['tax_rate'] = account_data.get('tax_rate')
- return frappe.get_doc(template).insert(ignore_permissions=True)
+ doc = frappe.get_doc(template)
+ doc.flags.ignore_links = True
+ doc.flags.ignore_validate = True
+ doc.insert(ignore_permissions=True)
+ return doc
def make_tax_category(tax_category):
""" Make tax category based on title if not already created """
doctype = 'Tax Category'
if not frappe.db.exists(doctype, tax_category):
tax_category['doctype'] = doctype
- frappe.get_doc(tax_category).insert(ignore_permissions=True)
+ doc = frappe.get_doc(tax_category)
+ doc.flags.ignore_links = True
+ doc.flags.ignore_validate = True
+ doc.insert(ignore_permissions=True)
def get_or_create_account(company_name, account):
"""
@@ -175,7 +185,8 @@
existing_accounts = frappe.get_list('Account',
filters={
'account_name': account.get('account_name'),
- 'account_number': account.get('account_number', '')
+ 'account_number': account.get('account_number', ''),
+ 'company': company_name
},
or_filters={
'company': company_name,
@@ -197,8 +208,11 @@
account['root_type'] = root_type
account['is_group'] = 0
- return frappe.get_doc(account).insert(ignore_permissions=True, ignore_mandatory=True)
-
+ doc = frappe.get_doc(account)
+ doc.flags.ignore_links = True
+ doc.flags.ignore_validate = True
+ doc.insert(ignore_permissions=True, ignore_mandatory=True)
+ return doc
def get_or_create_tax_group(company_name, root_type):
# Look for a group account of type 'Tax'
@@ -243,7 +257,11 @@
'account_type': 'Tax',
'account_name': account_name,
'parent_account': root_account.name
- }).insert(ignore_permissions=True)
+ })
+
+ tax_group_account.flags.ignore_links = True
+ tax_group_account.flags.ignore_validate = True
+ tax_group_account.insert(ignore_permissions=True)
tax_group_name = tax_group_account.name