Few comments:
1. You don't need to pass Object (or any its attributes) from client to server. Object is a part of the form structure and it's accessible on the server side.
2. Why are you getting the document form, Mesut? You need SalesOrder data that lives in the database, not in the document form.
3. The best and the simplest way of implementing this kind of functionality lives on the Generation tab of document properties (see pic). Open the SalesInvoice document properties and add SalesOrder to the upper frame of the form. Then run the Wizard that will help you to write the code you need. Please, take some time to look at this code and understand what it does and how.