Auto complete address in invoice module

I’m working on the invoices module and have added a relate field that’s connected to the products module.
(I have renamed the products module into the new contacts module as it is connected to the line items module.)

I would like the function that when a user enters a contact from the module in the relate field, the address is automatically grabbed from that contact and entered into the address fields for use with the pdf printing function.

How would I go about implementing that?

Try this :