Merge pull request #6690 from rohitwaghchaure/v7_pricing_rule_issue

[Fix] Pricing rule discount issue
diff --git a/erpnext/accounts/doctype/pricing_rule/pricing_rule.py b/erpnext/accounts/doctype/pricing_rule/pricing_rule.py
index b4fe148..f298bc8 100644
--- a/erpnext/accounts/doctype/pricing_rule/pricing_rule.py
+++ b/erpnext/accounts/doctype/pricing_rule/pricing_rule.py
@@ -165,6 +165,13 @@
 			})
 		else:
 			item_details.discount_percentage = pricing_rule.discount_percentage
+	elif args.get('pricing_rule'):
+		if frappe.db.get_value('Pricing Rule', args.get('pricing_rule'), 'price_or_discount') == 'Discount Percentage':
+			item_details.discount_percentage = 0.0
+
+		item_details.margin_rate_or_amount = 0.0
+		item_details.margin_type = None
+
 	return item_details
 
 def get_pricing_rules(args):
diff --git a/erpnext/public/js/controllers/taxes_and_totals.js b/erpnext/public/js/controllers/taxes_and_totals.js
index 4e1288c..64d48ea 100644
--- a/erpnext/public/js/controllers/taxes_and_totals.js
+++ b/erpnext/public/js/controllers/taxes_and_totals.js
@@ -15,10 +15,6 @@
 
 	},
 	apply_pricing_rule_on_item: function(item){
-		if(!item.margin_type){
-			item.margin_rate_or_amount = 0.0;
-		}
-
 		if(item.margin_type == "Percentage"){
 			item.total_margin = item.price_list_rate + item.price_list_rate * ( item.margin_rate_or_amount / 100);
 		}else{
diff --git a/erpnext/public/js/controllers/transaction.js b/erpnext/public/js/controllers/transaction.js
index 7ac9031..49a5af4 100644
--- a/erpnext/public/js/controllers/transaction.js
+++ b/erpnext/public/js/controllers/transaction.js
@@ -720,7 +720,8 @@
 					"brand": d.brand,
 					"qty": d.qty,
 					"parenttype": d.parenttype,
-					"parent": d.parent
+					"parent": d.parent,
+					"pricing_rule": d.pricing_rule
 				});
 
 				// if doctype is Quotation Item / Sales Order Iten then add Margin Type and rate in item_list