fix: Remove HR validations from Employee master
diff --git a/erpnext/setup/doctype/employee/employee.js b/erpnext/setup/doctype/employee/employee.js
index 8d15295..39a215f 100755
--- a/erpnext/setup/doctype/employee/employee.js
+++ b/erpnext/setup/doctype/employee/employee.js
@@ -18,15 +18,6 @@
erpnext.toggle_naming_series();
}
- date_of_birth() {
- return cur_frm.call({
- method: "get_retirement_date",
- args: {
- date_of_birth: this.frm.doc.date_of_birth
- }
- });
- }
-
salutation() {
if (this.frm.doc.salutation) {
this.frm.set_value("gender", {
diff --git a/erpnext/setup/doctype/employee/employee.py b/erpnext/setup/doctype/employee/employee.py
index 91e8cf3..84b1e51 100755
--- a/erpnext/setup/doctype/employee/employee.py
+++ b/erpnext/setup/doctype/employee/employee.py
@@ -10,7 +10,7 @@
remove_user_permission,
set_user_permission_if_allowed,
)
-from frappe.utils import add_years, cstr, getdate, today, validate_email_address
+from frappe.utils import cstr, getdate, today, validate_email_address
from frappe.utils.nestedset import NestedSet
from erpnext.utilities.transaction_base import delete_events
@@ -28,18 +28,7 @@
nsm_parent_field = "reports_to"
def autoname(self):
- naming_method = frappe.db.get_value("HR Settings", None, "emp_created_by")
- if not naming_method:
- throw(_("Please setup Employee Naming System in Human Resource > HR Settings"))
- else:
- if naming_method == "Naming Series":
- set_name_by_naming_series(self)
- elif naming_method == "Employee Number":
- self.name = self.employee_number
- elif naming_method == "Full Name":
- self.set_employee_name()
- self.name = self.employee_name
-
+ set_name_by_naming_series(self)
self.employee = self.name
def validate(self):
@@ -54,8 +43,6 @@
self.validate_status()
self.validate_reports_to()
self.validate_preferred_email()
- if self.job_applicant:
- self.validate_onboarding_process()
if self.user_id:
self.validate_user_details()
@@ -248,30 +235,11 @@
def on_trash(self):
self.update_nsm_model()
delete_events(self.doctype, self.name)
- if frappe.db.exists("Employee Transfer", {"new_employee_id": self.name, "docstatus": 1}):
- emp_transfer = frappe.get_doc(
- "Employee Transfer", {"new_employee_id": self.name, "docstatus": 1}
- )
- emp_transfer.db_set("new_employee_id", "")
def validate_preferred_email(self):
if self.prefered_contact_email and not self.get(scrub(self.prefered_contact_email)):
frappe.msgprint(_("Please enter {0}").format(self.prefered_contact_email))
- def validate_onboarding_process(self):
- employee_onboarding = frappe.get_all(
- "Employee Onboarding",
- filters={
- "job_applicant": self.job_applicant,
- "docstatus": 1,
- "boarding_status": ("!=", "Completed"),
- },
- )
- if employee_onboarding:
- doc = frappe.get_doc("Employee Onboarding", employee_onboarding[0].name)
- doc.validate_employee_creation()
- doc.db_set("employee", self.name)
-
def reset_employee_emails_cache(self):
prev_doc = self.get_doc_before_save() or {}
cell_number = cstr(self.get("cell_number"))
@@ -281,35 +249,6 @@
frappe.cache().hdel("employees_with_number", prev_number)
-def get_timeline_data(doctype, name):
- """Return timeline for attendance"""
- return dict(
- frappe.db.sql(
- """select unix_timestamp(attendance_date), count(*)
- from `tabAttendance` where employee=%s
- and attendance_date > date_sub(curdate(), interval 1 year)
- and status in ('Present', 'Half Day')
- group by attendance_date""",
- name,
- )
- )
-
-
-@frappe.whitelist()
-def get_retirement_date(date_of_birth=None):
- ret = {}
- if date_of_birth:
- try:
- retirement_age = int(frappe.db.get_single_value("HR Settings", "retirement_age") or 60)
- dt = add_years(getdate(date_of_birth), retirement_age)
- ret = {"date_of_retirement": dt.strftime("%Y-%m-%d")}
- except ValueError:
- # invalid date
- ret = {}
-
- return ret
-
-
def validate_employee_role(doc, method):
# called via User hook
if "Employee" in [d.role for d in doc.get("roles")]: