Can I Override site.assets.frappe.js.frappe.view.kanban.kanban_board.js file

Can I override frappe js file

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

Please help

You can try to override by writing in your apps public folder, but not sure will it override need to check the sequence of execution

@khushal_t OK whta i use

web_include_js
app_include_js
webform_include_js
page_js

which hooks.py method i will use
https://frappeframework.com/docs/v13/user/en/python-api/hooks#javascript-css-assets

@Antony_Praveenkumar if the method you want to override is page you should use page_js

@khushal_t It’s not page
site.assets.frappe.js.frappe.view.kanban.kanban_board.js
this is the js file location

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 corectlyd

3 Likes

not working for me can you please share some example to overwrite
frappe.view.map.map_view.js

Below or equal this version is kanban is working

ERPNext: v13.22.1 (version-13)
Frappe Framework: v13.22.1 (version-13)

But for this version or above version kanban is not working

ERPNext: v13.36.3 (version-13)
Frappe Framework: v13.37.0 (version-13)

Please check your version @pratikcws

I’d like to do this but for Frappe UI in general. Are there any resources I can use for this? Specifically desk.js

Is there any way or method for erpnext version 14?