Frappe Framework still not allow to extend (and not override) List View?

I want to extend the doctype list view on onload functoin, i.e., adding menu, etc.

By using

doctype_list_js = {
“Salary Slip”: “public/js/salary_slip_list.js”,

However, from experiment (and by reading in this forum), the function onload is completely overwritten, which means, the core feature is gone.

AFAIK, the extending of the Form view is OK to be extended using similar method.
doctype_js = {
“Salary Slip”: “public/js/salary_slip.js”,

Am I correct? And are there work around for the list view?

Hi @kittiu,

It’s worked properly and also I checked from my end. Please check the video.

bench build --force

I hope this helps.

Thank You!

It’s not overridden completely, just extended.

Here’s where it happens:

1 Like

But what you did is overriding also, isn’t it?

If not, now you should have 2 menus,

  1. Email Salary Slip → from core hr module
  2. Email Salary Slip | NCP → from your custom module

What you did override the one from core hr.

And so, in my case to keep the existing “Email Salary Slip” while adding a new menu, I need to duplicate the code here.

If I have more than 1 module, this is not easy to maintain.

frappe.listview_settings["Salary Slip"] = {

	onload: function(listview) {

		// Override apps/hrms/hrms/payroll/doctype/salary_slip/salary_slip_list.js
		if (!has_common(frappe.user_roles, ["Administrator", "System Manager", "HR Manager", "HR User"])) return;"Email Salary Slips"), () => {
			if (!listview.get_checked_items().length) {
				frappe.msgprint(__("Please select the salary slips to email"));

			frappe.confirm(__("Are you sure you want to email the selected salary slips?"), () => {
		// --
		// Addition"Withholding Tax Cert Employee"), ()=>{
				"Salary Slip",
				"Withholding Tax Cert Employee"


If this is the only solution, I would not say it is extendable (but override-able).

Please proof me wrong.

function extend_listview_event(doctype, event, callback) {
    if (!frappe.listview_settings[doctype]) {
        frappe.listview_settings[doctype] = {};

    const old_event = frappe.listview_settings[doctype][event];
    frappe.listview_settings[doctype][event] = function (listview) {
        if (old_event) {

extend_listview_event("Salary Slip", "onload", function (listview) {
    // your code here

Hope this helps :slight_smile:


Thank you, this works! These kind of tricks should be collected into a cheat sheet !

1 Like

It works :pray:

1 Like