diff --git a/erpnext/patches/v7_0/move_employee_parent_to_child_in_salary_structure.py b/erpnext/patches/v7_0/move_employee_parent_to_child_in_salary_structure.py index 509c0a866b..23f2778bb7 100644 --- a/erpnext/patches/v7_0/move_employee_parent_to_child_in_salary_structure.py +++ b/erpnext/patches/v7_0/move_employee_parent_to_child_in_salary_structure.py @@ -5,7 +5,9 @@ def execute(): frappe.reload_doc('hr', 'doctype', 'salary_structure_employee') for ss in frappe.db.sql(""" select employee, name from `tabSalary Structure`""", as_dict=True): ss_doc = frappe.get_doc('Salary Structure', ss.name) - se = ss_doc.append('employees',{}) - se.employee = ss.employee - se.base = 0 + salary_employee = ss_doc.append('employees',{}) + salary_employee.employee = ss.employee + salary_employee.base = 0 + if not ss_doc.company: + ss_doc.company = frappe.db.get_value('Employee', salary_employee.employee, 'company') ss_doc.save()