How to override javascript function in the bundle file (dimension_tree_filter.js)

I know that we can override javascript using doctype_js…

But if what is in the erpnext.bundle.js i.e., dimension_tree_filter.js, how to override or monkey patch it?

To be specific, given the following code in the JS file,

frappe.provide('erpnext.accounts');

erpnext.accounts.dimensions = {
	setup_dimension_filters(frm, doctype) {
		this.accounting_dimensions = [];
		this.default_dimensions = {};
		this.fetch_custom_dimensions(frm, doctype);
	},

...

I want to override function setup_dimension_filters() in order to remove line this.fetch_custom_dimensions(frm, doctype);

Is this possible?
Thank you

1 Like

does you found the solution ?

This should work in your custom work:

erpnext.accounts.dimensions.setup_dimension_filters = function(frm, doctype) {
    this.accounting_dimensions = [];
    this.default_dimensions = {};
    // this.fetch_custom_dimensions(frm, doctype);
};