Edit built-in doctype scripts

Is it okay to edit built-in doctypes scripts or we should create a copy and then edit in it?

More details will helpful.
You can use

for modifications.

Edit 2022-01-13: Updated links

@royprotim,

You can edit the doctypes and make the customization but then you will have to maintain the repo for the frappe/erpnext but you might get the conflicts while updating or upgrading.

A better option would be to use the Custom Script.

please check

http://frappe.github.io/erpnext/user/manual/en/customize-erpnext/custom-scripts/custom-script-examples/

Update 2022-01-13: Client Scripts

But how can we write python part in custom scripts?

I need to get data from other doctypes for which we need to edit doctype.py and doctype.js files in the server as shown in the scripting tutorial by erpnext.

Also if I add some extra custom fields to the built-in doctypes, will they also create conflicts while updating or upgrading? Or they will be overwritten?

Refer to the link for more info.