Add custom filter to the Process Payroll

hi, i want add new filter to the Process Payroll that will work similar to ‘branch’, ‘department’, designation’ filters

so what i did so far is:
1- added custom field to Employee with name emp_ab
2- added custom field to Process Payroll emp_ab
3 added emp_ab to the get_filter_condition function in …hr/doctype/process_payroll/
4- next step ???

any hint on this?, thanks


you followed correct steps so far.
Can you share changes from

you have to just add your filter condition into it.

def get_filter_condition(self):

		cond = ''
		for f in ['company', 'branch', 'department', 'designation', 'emp_ab']:
			if self.get(f):
				cond += " and t1." + f + " = '" + self.get(f).replace("'", "\'") + "'"

		return cond
1 Like

thanks for reply

yes i just add ‘emp_ab’ to the list:

for f in [‘company’, ‘branch’, ‘department’, ‘designation’, ‘emp_ab’]:

but that did not work, i will try add the fields this time using doctype instead of customize form and see if that work.

you mean to say it is not filtering Employee List as per emp_ab or Is there any error?

Please check your query generated, especially cond (Condition) part. Debug the query will get the answer.

		emp_list = frappe.db.sql("""
			from `tabEmployee` t1, `tabSalary Structure Employee` t2
			where t1.docstatus!=2 and = t2.employee
		%s """% cond, {"sal_struct": sal_struct})

		return emp_list

Cross verify emp_ab field value from both Employee and Process Payroll

1 Like

yes its not filtering when i click ‘create salary slip’ button.
that field type is link to Project so i just want filter employees based on this

Make sure your field name on both Doctypes(Employee and Process Payroll) is emp_ab. If yes it has to work.

1 Like