How to Override kanban_board.js

Is ther any possible to override

file location : site.assets.frappe.js.frappe.view.kanban.kanban_board.js

Answer : YES we can But not in the hooks

we have a file in frappe frappe.client.get_js

get_js() is whitelist function you can override that function like this

Note: ss_custom_erpnext = custom_app

override_whitelisted_methods = {
“frappe.client.get_js”:“ss_custom_erpnext.ss_custom_erpnext.hr.doctype.kanban_board.kanban_board.get_js”,
}

create kanban_board.py (in custom app)

indent preformatted text by 4 spaces

   @frappe.whitelist()
    def get_js(items):

‘’'Load JS code files. Will also append translations
and extend frappe._messages

:param items: JSON list of paths of the js files to be loaded.‘’’

‘’’
This is the function trigger this file location : site.assets.frappe.js.frappe.view.kanban.kanban_board.js

correct:
contentpath = ‘./assets/frappe/js/frappe/views/kanban/kanban_board.js’

overrided path:
‘./assets/ss_custom_erpnext/js/kanban_board.js’

‘’’
indent preformatted text by 4 spaces.

       items = json.loads(items)
    out = []
    for src in items:
    src = src.strip("/").split("/")

	if ".." in src or src[0] != "assets":
		frappe.throw(_("Invalid file path: {0}").format("/".join(src)))

	contentpath = os.path.join(frappe.local.sites_path, *src)

	if not contentpath == './assets/frappe/js/frappe/views/kanban/kanban_board.js':
		with open(contentpath, "r") as srcfile:
			code = frappe.utils.cstr(srcfile.read())
	else:
		contentpath = './assets/ss_custom_erpnext/js/kanban_board.js'
		with open(contentpath, "r") as srcfile:
			code = frappe.utils.cstr(srcfile.read())

	if frappe.local.lang != "en":
		messages = frappe.get_lang_dict("jsfile", contentpath)
		messages = json.dumps(messages)
		code += "\n\n$.extend(frappe._messages, {})".format(messages)

	out.append(code)

Blockquote
this will work corectly

1 Like