Duplicate Doctype and Doctype Code

Hello everyone,

So I was wondering, is it possible to make duplicate a DocType and the underlying Code as well?

For example, if I have the default Sales Order DocType and duplicate it, can I duplicate the code so that the custom doctype performs all the tasks and calculations (like calculating totals)? I want ALL the code and not just parts of the code.

I know you can view the source code, but I don’t want to have to go through the source code and manually enter in the code.

Any help is appreciated.