Sales Order get_mapped_doc

I need to map all the fields in the sales order to sales invoice.
I have custom amount in the sales order items table because i need to fix the amount and rate is to calculated from qty and amount. (Hide the default ‘amount’ field).
While adding items or when page refreshes the amount is calculated back to qty * rate. In order to stop this re-calculation and to fix the amount i did the following.

  1. called the below function in hook on validate:
    def make_amount_constant(doc,method):

    frappe.msgprint(_(“I am from hook method”))

     if self.doctype == "Sales Order":
     	total = 0				
     	for d in self.get("items"):
     		d.amount = d.custom_amount
     		total += d.custom_amount
     = total
     	self.grand_total = total
     	self.net_total =total
     	self.base_total =total
     	self.base_net_total = total
     	self.base_grand_total = total 
     	self.base_rounded_total  =total 
     	self.rounded_total =total
  2. wrote the function in sales_order.js

    frappe.ui.form.on(“Sales Order”, {
    refresh:function(doc,dt,dn) {
    // alert(“Refreshing”);
    var totals=0;

     	for(key in cur_frm.doc.items)
     		var row = cur_frm.doc.items[key];
     		var area  = row.qty;
     		total = row.custom_amount;	
     		row['rate'] = flt((total/area),2);
     		row.amount = row.custom_amount;
     		if(row.custom_amount != undefined)
     			totals  = totals + total;

    // alert(“HII”);

     	cur_frm.set_value("total", totals);	
     	cur_frm.set_value("grand_total", totals);
     	cur_frm.set_value("net_total", totals);
     	cur_frm.set_value("base_rounded_total", totals);	
     	cur_frm.set_value("base_total", totals);
     	cur_frm.set_value("base_net_total", totals);
     	cur_frm.set_value("base_grand_total", totals);	
     	cur_frm.set_value("rounded_total", totals);	

    // alert(totals);
    // cur_frm.refresh_fields();
    // cur_frm.cscript.custom_refresh(totals);

But the fixed total, grand total, rounded total are not same in sales invoice, when MAKE invoice from sales order

How can I make value same in sales invoice as sales order.???

You will have to do it server-side, probably write a hook on validate that will re-write the totals based on your custom field.