Merge pull request #6925 from rmehta/setup-wizard-fix
[fix] ignore duplicate names for program, academic term, academic year, course, instructor
This commit is contained in:
commit
6209f2f75b
@ -68,7 +68,7 @@ def setup_complete(args=None):
|
|||||||
frappe.message_log.pop()
|
frappe.message_log.pop()
|
||||||
|
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def create_fiscal_year_and_company(args):
|
def create_fiscal_year_and_company(args):
|
||||||
if (args.get('fy_start_date')):
|
if (args.get('fy_start_date')):
|
||||||
curr_fiscal_year = get_fy_details(args.get('fy_start_date'), args.get('fy_end_date'))
|
curr_fiscal_year = get_fy_details(args.get('fy_start_date'), args.get('fy_end_date'))
|
||||||
@ -244,12 +244,12 @@ def get_fy_details(fy_start_date, fy_end_date):
|
|||||||
else:
|
else:
|
||||||
fy = cstr(start_year) + '-' + cstr(start_year + 1)
|
fy = cstr(start_year) + '-' + cstr(start_year + 1)
|
||||||
return fy
|
return fy
|
||||||
|
|
||||||
def create_sales_tax(args):
|
def create_sales_tax(args):
|
||||||
country_wise_tax = get_country_wise_tax(args.get("country"))
|
country_wise_tax = get_country_wise_tax(args.get("country"))
|
||||||
if country_wise_tax and len(country_wise_tax) > 0:
|
if country_wise_tax and len(country_wise_tax) > 0:
|
||||||
for sales_tax, tax_data in country_wise_tax.items():
|
for sales_tax, tax_data in country_wise_tax.items():
|
||||||
make_tax_account_and_template(args.get("company_name").strip(),
|
make_tax_account_and_template(args.get("company_name").strip(),
|
||||||
tax_data.get('account_name'), tax_data.get('tax_rate'), sales_tax)
|
tax_data.get('account_name'), tax_data.get('tax_rate'), sales_tax)
|
||||||
|
|
||||||
def get_country_wise_tax(country):
|
def get_country_wise_tax(country):
|
||||||
@ -267,7 +267,7 @@ def create_taxes(args):
|
|||||||
account_name = args.get("tax_" + str(i))
|
account_name = args.get("tax_" + str(i))
|
||||||
|
|
||||||
make_tax_account_and_template(args.get("company_name").strip(), account_name, tax_rate)
|
make_tax_account_and_template(args.get("company_name").strip(), account_name, tax_rate)
|
||||||
|
|
||||||
def make_tax_account_and_template(company, account_name, tax_rate, template_name=None):
|
def make_tax_account_and_template(company, account_name, tax_rate, template_name=None):
|
||||||
try:
|
try:
|
||||||
account = make_tax_account(company, account_name, tax_rate)
|
account = make_tax_account(company, account_name, tax_rate)
|
||||||
@ -280,14 +280,14 @@ def make_tax_account_and_template(company, account_name, tax_rate, template_name
|
|||||||
raise
|
raise
|
||||||
except RootNotEditable, e:
|
except RootNotEditable, e:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def get_tax_account_group(company):
|
def get_tax_account_group(company):
|
||||||
tax_group = frappe.db.get_value("Account",
|
tax_group = frappe.db.get_value("Account",
|
||||||
{"account_name": "Duties and Taxes", "is_group": 1, "company": company})
|
{"account_name": "Duties and Taxes", "is_group": 1, "company": company})
|
||||||
if not tax_group:
|
if not tax_group:
|
||||||
tax_group = frappe.db.get_value("Account", {"is_group": 1, "root_type": "Liability",
|
tax_group = frappe.db.get_value("Account", {"is_group": 1, "root_type": "Liability",
|
||||||
"account_type": "Tax", "company": company})
|
"account_type": "Tax", "company": company})
|
||||||
|
|
||||||
return tax_group
|
return tax_group
|
||||||
|
|
||||||
def make_tax_account(company, account_name, tax_rate):
|
def make_tax_account(company, account_name, tax_rate):
|
||||||
@ -308,7 +308,7 @@ def make_tax_account(company, account_name, tax_rate):
|
|||||||
def make_sales_and_purchase_tax_templates(account, template_name=None):
|
def make_sales_and_purchase_tax_templates(account, template_name=None):
|
||||||
if not template_name:
|
if not template_name:
|
||||||
template_name = account.name
|
template_name = account.name
|
||||||
|
|
||||||
sales_tax_template = {
|
sales_tax_template = {
|
||||||
"doctype": "Sales Taxes and Charges Template",
|
"doctype": "Sales Taxes and Charges Template",
|
||||||
"title": template_name,
|
"title": template_name,
|
||||||
@ -548,35 +548,50 @@ def create_academic_term():
|
|||||||
academic_term = frappe.new_doc("Academic Term")
|
academic_term = frappe.new_doc("Academic Term")
|
||||||
academic_term.academic_year = y
|
academic_term.academic_year = y
|
||||||
academic_term.term_name = t
|
academic_term.term_name = t
|
||||||
academic_term.save()
|
try:
|
||||||
|
academic_term.save()
|
||||||
|
except frappe.DuplicateEntryError:
|
||||||
|
pass
|
||||||
|
|
||||||
def create_academic_year():
|
def create_academic_year():
|
||||||
ac = ["2013-14", "2014-15", "2015-16", "2016-17", "2017-18"]
|
ac = ["2013-14", "2014-15", "2015-16", "2016-17", "2017-18"]
|
||||||
for d in ac:
|
for d in ac:
|
||||||
academic_year = frappe.new_doc("Academic Year")
|
academic_year = frappe.new_doc("Academic Year")
|
||||||
academic_year.academic_year_name = d
|
academic_year.academic_year_name = d
|
||||||
academic_year.save()
|
try:
|
||||||
|
academic_year.save()
|
||||||
|
except frappe.DuplicateEntryError:
|
||||||
|
pass
|
||||||
|
|
||||||
def create_program(args):
|
def create_program(args):
|
||||||
for i in xrange(1,6):
|
for i in xrange(1,6):
|
||||||
if args.get("program_" + str(i)):
|
if args.get("program_" + str(i)):
|
||||||
program = frappe.new_doc("Program")
|
program = frappe.new_doc("Program")
|
||||||
program.program_name = args.get("program_" + str(i))
|
program.program_name = args.get("program_" + str(i))
|
||||||
program.save()
|
try:
|
||||||
|
program.save()
|
||||||
|
except frappe.DuplicateEntryError:
|
||||||
|
pass
|
||||||
|
|
||||||
def create_course(args):
|
def create_course(args):
|
||||||
for i in xrange(1,6):
|
for i in xrange(1,6):
|
||||||
if args.get("course_" + str(i)):
|
if args.get("course_" + str(i)):
|
||||||
course = frappe.new_doc("Course")
|
course = frappe.new_doc("Course")
|
||||||
course.course_name = args.get("course_" + str(i))
|
course.course_name = args.get("course_" + str(i))
|
||||||
course.save()
|
try:
|
||||||
|
course.save()
|
||||||
|
except frappe.DuplicateEntryError:
|
||||||
|
pass
|
||||||
|
|
||||||
def create_instructor(args):
|
def create_instructor(args):
|
||||||
for i in xrange(1,6):
|
for i in xrange(1,6):
|
||||||
if args.get("instructor_" + str(i)):
|
if args.get("instructor_" + str(i)):
|
||||||
instructor = frappe.new_doc("Instructor")
|
instructor = frappe.new_doc("Instructor")
|
||||||
instructor.instructor_name = args.get("instructor_" + str(i))
|
instructor.instructor_name = args.get("instructor_" + str(i))
|
||||||
instructor.save()
|
try:
|
||||||
|
instructor.save()
|
||||||
|
except frappe.DuplicateEntryError:
|
||||||
|
pass
|
||||||
|
|
||||||
def create_room(args):
|
def create_room(args):
|
||||||
for i in xrange(1,6):
|
for i in xrange(1,6):
|
||||||
@ -584,6 +599,9 @@ def create_room(args):
|
|||||||
room = frappe.new_doc("Room")
|
room = frappe.new_doc("Room")
|
||||||
room.room_name = args.get("room_" + str(i))
|
room.room_name = args.get("room_" + str(i))
|
||||||
room.seating_capacity = args.get("room_capacity_" + str(i))
|
room.seating_capacity = args.get("room_capacity_" + str(i))
|
||||||
room.save()
|
try:
|
||||||
|
room.save()
|
||||||
|
except frappe.DuplicateEntryError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user