Chart of accounts add custom field with child account issue

I’m trying to add account code to be visible in the account tree beside each account, I’m done with that but; when I want to add child account, I added the account code field in the dialog and its suggested value should be serialized as its parent code + its siblings count +1 the question is how could I read the parent code to make my simple calculation for the new child code to be shown in my custom field inside the dialog.
here is a picture for what I done till now:

1 Like

Add a hook to the validate method of Account and set your custom field value in that method so that it is set just before the record is written.

Check section on CRUD events here:

Thanks @rmehta for your response, but the validate method will fire after I press “Create New” but what actually I need the method that fired after I press “Add Child” or “New” because I want to set my custom field value which is based on the clicked account( i.e, to get the account code of the clicked account and make some calculations) and then be shown in the dialog before creating it.

Thanks in advance

Maybe then make your own view by copying it.

IMO making it work with validate is the best option.

How I can overwrite the new_node function in the erpnext/accounts/doctype/account/account_tree.js
which is written in the frappe treeview.js

I want to customize or overwrite the new_node function specially the following portion:

me.args[“parent_”+me.doctype.toLowerCase()] = me.args[“parent”];
d.set_value(“is_group”, 0);