I want to copy and paste an invoice but I get this error:

what was done in version :

a solution was made in code changing the CurrentDocument by the Document where it allows copy and paste but leaving the invoice form and settings ... and it is entered again .…
But there is another problem that with that change when I create an invoice, I save it, the info of the other tabs of the invoice are erased... if I refresh the screen it appears...
if this happens to someone, please help me