When does rate gets populated in Sales return?

Suggestion:
User has to enter or select the invoice numbe in Sales return item detail. The invoice against which the Sales return has been made. The invoice number repeats to take a single return against multiple invoices. Then, The detail line number of the invoice against which the Sales return has been made should be entered. Once the details line number is entered, item code and details gets popuated. Users then has to select the lot numberand lot sl. when lot number is entered item rate gets populated.