From 14ad9f70b5e43ddcfa346f63faa72eb7a436fb83 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Tue, 31 Jul 2018 17:33:03 +0530 Subject: [PATCH] Patch fixes --- .../leave_encashment/test_leave_encashment.py | 3 +-- .../hr/doctype/leave_period/test_leave_period.py | 7 +------ .../create_department_records_for_each_company.py | 2 +- .../v11_0/create_salary_structure_assignments.py | 13 +++++++++---- 4 files changed, 12 insertions(+), 13 deletions(-) diff --git a/erpnext/hr/doctype/leave_encashment/test_leave_encashment.py b/erpnext/hr/doctype/leave_encashment/test_leave_encashment.py index 2029973aac8..ef5c2aa6f39 100644 --- a/erpnext/hr/doctype/leave_encashment/test_leave_encashment.py +++ b/erpnext/hr/doctype/leave_encashment/test_leave_encashment.py @@ -37,8 +37,7 @@ class TestLeaveEncashment(unittest.TestCase): # create the leave period and assign the leaves leave_period = create_leave_period(add_months(today(), -3), add_months(today(), 3)) - leave_period.employee = employee - leave_period.grant_leave_allocation() + leave_period.grant_leave_allocation(employee=employee) leave_encashment = frappe.get_doc(dict( doctype = 'Leave Encashment', diff --git a/erpnext/hr/doctype/leave_period/test_leave_period.py b/erpnext/hr/doctype/leave_period/test_leave_period.py index 3fb035fa87a..850a08dd536 100644 --- a/erpnext/hr/doctype/leave_period/test_leave_period.py +++ b/erpnext/hr/doctype/leave_period/test_leave_period.py @@ -40,14 +40,9 @@ class TestLeavePeriod(unittest.TestCase): leave_period = create_leave_period(add_months(today(), -3), add_months(today(), 3)) # test leave_allocation - leave_period.employee = employee_doc_name - leave_period.grant_leave_allocation() + leave_period.grant_leave_allocation(employee=employee_doc_name) self.assertEqual(get_leave_balance_on(employee_doc_name, leave_type, today()), 20) - # leave_period.grant_leave_alloc(employee_doc_name) - self.assertRaises(frappe.ValidationError, leave_period.grant_leave_allocation) - - def create_leave_period(from_date, to_date): leave_period = frappe.get_doc({ "doctype": "Leave Period", diff --git a/erpnext/patches/v11_0/create_department_records_for_each_company.py b/erpnext/patches/v11_0/create_department_records_for_each_company.py index a5b76e96c50..da97476fd35 100644 --- a/erpnext/patches/v11_0/create_department_records_for_each_company.py +++ b/erpnext/patches/v11_0/create_department_records_for_each_company.py @@ -30,7 +30,7 @@ def execute(): comp_dict[company.name][department.name] = copy_doc.name rebuild_tree('Department', 'parent_department') - doctypes = ["Asset", "Employee", "Leave Period", "Payroll Entry", "Staffing Plan", "Job Opening"] + doctypes = ["Asset", "Employee", "Payroll Entry", "Staffing Plan", "Job Opening"] for d in doctypes: update_records(d, comp_dict) diff --git a/erpnext/patches/v11_0/create_salary_structure_assignments.py b/erpnext/patches/v11_0/create_salary_structure_assignments.py index 596fe8418dc..2dab1940d8a 100644 --- a/erpnext/patches/v11_0/create_salary_structure_assignments.py +++ b/erpnext/patches/v11_0/create_salary_structure_assignments.py @@ -21,11 +21,16 @@ def execute(): where ss.name = sse.parent AND ss.is_active='Yes' AND sse.employee in (select name from `tabEmployee` where ifNull(status, '') != 'Left')""", as_dict=1) else: + cols = "" + if "base" in frappe.db.get_table_columns("Salary Structure"): + cols = ", base, variable" + ss_details = frappe.db.sql(""" - select name as salary_structure, employee, employee_name, from_date, to_date, base, variable, company + select name as salary_structure, employee, employee_name, from_date, to_date, company {0} from `tabSalary Structure` where is_active='Yes' - AND sse.employee in (select name from `tabEmployee` where ifNull(status, '') != 'Left')""", as_dict=1) + AND employee in (select name from `tabEmployee` where ifNull(status, '') != 'Left') + """.format(cols), as_dict=1) for d in ss_details: try: @@ -35,8 +40,8 @@ def execute(): s.salary_structure = d.salary_structure s.from_date = d.from_date s.to_date = d.to_date if isinstance(d.to_date, datetime) else None - s.base = d.base - s.variable = d.variable + s.base = d.get("base") + s.variable = d.get("variable") s.company = d.company # to migrate the data of the old employees