From 33c1a38dc85d99805be6f5b3f1b2c012f129d5d1 Mon Sep 17 00:00:00 2001 From: Manas Solanki Date: Fri, 18 May 2018 15:46:35 +0530 Subject: [PATCH] [fix] patch for the salary structure assignment for old employees --- .../salary_structure_assignment.py | 6 ++++-- .../patches/v11_0/create_salary_structure_assignments.py | 3 +++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/erpnext/hr/doctype/salary_structure_assignment/salary_structure_assignment.py b/erpnext/hr/doctype/salary_structure_assignment/salary_structure_assignment.py index 26e7fce9fe..67217490e1 100644 --- a/erpnext/hr/doctype/salary_structure_assignment/salary_structure_assignment.py +++ b/erpnext/hr/doctype/salary_structure_assignment/salary_structure_assignment.py @@ -21,7 +21,9 @@ class SalaryStructureAssignment(Document): if joining_date and getdate(self.from_date) < joining_date: frappe.throw(_("From Date {0} cannot be before employee's joining Date {1}") .format(self.from_date, joining_date)) - if relieving_date and getdate(self.from_date) > relieving_date: + + # flag - old_employee is for migrating the old employees data via patch + if relieving_date and getdate(self.from_date) > relieving_date and not self.flags.old_employee: frappe.throw(_("From Date {0} cannot be after employee's relieving Date {1}") .format(self.from_date, relieving_date)) @@ -29,7 +31,7 @@ class SalaryStructureAssignment(Document): if self.from_date and getdate(self.from_date) > getdate(self.to_date): frappe.throw(_("From Date {0} cannot be after To Date {1}") .format(self.from_date, self.to_date)) - if relieving_date and getdate(self.to_date) > relieving_date: + if relieving_date and getdate(self.to_date) > relieving_date and not self.flags.old_employee: frappe.throw(_("To Date {0} cannot be after employee's relieving Date {1}") .format(self.to_date, relieving_date)) diff --git a/erpnext/patches/v11_0/create_salary_structure_assignments.py b/erpnext/patches/v11_0/create_salary_structure_assignments.py index 289554ee1a..24874f604a 100644 --- a/erpnext/patches/v11_0/create_salary_structure_assignments.py +++ b/erpnext/patches/v11_0/create_salary_structure_assignments.py @@ -18,6 +18,9 @@ def execute(): s.base = d.base s.variable = d.variable s.company = d.company + + # to migrate the data of the old employees + s.flags.old_employee = True s.save() frappe.db.sql("update `tabSalary Structure` set docstatus=1") \ No newline at end of file