fix: Ignore validations for Tax Setup
This commit is contained in:
@@ -123,8 +123,11 @@ def make_taxes_and_charges_template(company_name, doctype, template):
|
||||
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.
|
||||
@@ -149,14 +152,21 @@ def make_item_tax_template(company_name, template):
|
||||
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):
|
||||
"""
|
||||
@@ -169,7 +179,8 @@ def get_or_create_account(company_name, account):
|
||||
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,
|
||||
@@ -191,8 +202,11 @@ def get_or_create_account(company_name, account):
|
||||
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'
|
||||
@@ -237,7 +251,11 @@ def get_or_create_tax_group(company_name, root_type):
|
||||
'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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user