Override validate function & employee.list

There is a function validate on erpnext/erpnext/hr/doctype/employee.py I want to add more status on validate function. But, I do not want to do it directly on that file since it will modify source code and it will give me problem when I upgrade.

validate_status(self.status, [“Active”, “Temporary Leave”, “Left”])

I want to add some more status & modify employee.list to change color indicator of new status

help me please

Did you find a way to do this ?

ERPNext: v14.27.1 (version-14)
Frappe Framework: v14.38.2 (version-14)

I have added on status (Test) in the validate method.
Override Class not working. can anyone help?

custom_emp.py

import frappe, erpnext
from erpnext.setup.doctype.employee.employee import Employee
from frappe.utils.nestedset import NestedSet
from erpnext.controllers.status_updater import validate_status

class CustomEmployee(Employee(NestedSet)):
    def validate(self):
        self.my_custom_code()
        super().validate()

    def my_custom_code(self):
        validate_status(self.status, ["Active", "Inactive", "Suspended", "Left", "Test"])

hooks.py

override_doctype_class = {
    "Employee" : "mytest.overrides.custom_emp.CustomEmployee"

Thanks.

anyone ??

Its not working due to HRMS app already overriding Employee doctype.
Go to Installed Application doctype and Update Hooks resolution order and keep your custom app last in the order.

Note: Keep hrms doctype override code in your custom app only one override work at a time

1 Like

@niyaz_razak , Thanks a lot, It’s resolved.

1 Like