Allow changing export_rate if discount=0, then calculate discount based on ref_rate and export_rate (valid for non inclusive pricing)
diff --git a/erpnext/selling/doctype/sales_common/sales_common.js b/erpnext/selling/doctype/sales_common/sales_common.js
index 8876fa4..5039fcd 100644
--- a/erpnext/selling/doctype/sales_common/sales_common.js
+++ b/erpnext/selling/doctype/sales_common/sales_common.js
@@ -168,6 +168,13 @@
 
 // ************************ EXPORT RATE *************************
 cur_frm.cscript.export_rate = function(doc,cdt,cdn) {
+	var cur_rec = locals[cdt][cdn];
+	var fname = cur_frm.cscript.fname;
+	var tname = cur_frm.cscript.tname;
+	if(flt(cur_rec.ref_rate)>0 && flt(cur_rec.export_rate)>0 && !flt(cur_rec.adj_rate)) {
+		var adj_rate = 100 * (1 - (flt(cur_rec.export_rate) / flt(cur_rec.ref_rate)));
+		set_multiple(tname, cur_rec.name, { 'adj_rate': adj_rate }, fname);
+	}
 	doc = locals[doc.doctype][doc.name];
 	cur_frm.cscript.recalc(doc, 1);
 }
diff --git a/version.num b/version.num
index c2807f7..acfba60 100644
--- a/version.num
+++ b/version.num
@@ -1 +1 @@
-140
\ No newline at end of file
+141
\ No newline at end of file