Merge pull request #19996 from rohitwaghchaure/fixed_pricing_rule_issue_for_product_discount_develop
fix: Pricing Rule Discount for Product
diff --git a/erpnext/accounts/doctype/pricing_rule/pricing_rule.json b/erpnext/accounts/doctype/pricing_rule/pricing_rule.json
index f73fb10..29d8378 100644
--- a/erpnext/accounts/doctype/pricing_rule/pricing_rule.json
+++ b/erpnext/accounts/doctype/pricing_rule/pricing_rule.json
@@ -1,5 +1,4 @@
{
- "actions": [],
"allow_import": 1,
"allow_rename": 1,
"autoname": "field:title",
@@ -390,8 +389,7 @@
"fieldname": "rate_or_discount",
"fieldtype": "Select",
"label": "Rate or Discount",
- "options": "\nRate\nDiscount Percentage\nDiscount Amount",
- "reqd": 1
+ "options": "\nRate\nDiscount Percentage\nDiscount Amount"
},
{
"default": "Grand Total",
@@ -440,7 +438,7 @@
},
{
"default": "0",
- "depends_on": "eval:!doc.mixed_conditions && doc.price_or_product_discount == 'Price'",
+ "depends_on": "eval:!doc.mixed_conditions && doc.apply_on != 'Transaction'",
"fieldname": "same_item",
"fieldtype": "Check",
"label": "Same Item"
@@ -556,8 +554,7 @@
],
"icon": "fa fa-gift",
"idx": 1,
- "links": [],
- "modified": "2019-12-13 15:48:48.331495",
+ "modified": "2019-12-18 17:29:22.957077",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Pricing Rule",
diff --git a/erpnext/accounts/doctype/pricing_rule/pricing_rule.py b/erpnext/accounts/doctype/pricing_rule/pricing_rule.py
index b99c07e..3c14819 100644
--- a/erpnext/accounts/doctype/pricing_rule/pricing_rule.py
+++ b/erpnext/accounts/doctype/pricing_rule/pricing_rule.py
@@ -47,6 +47,9 @@
if tocheck and not self.get(tocheck):
throw(_("{0} is required").format(self.meta.get_label(tocheck)), frappe.MandatoryError)
+ if self.price_or_product_discount == 'Price' and not self.rate_or_discount:
+ throw(_("Rate or Discount is required for the price discount."), frappe.MandatoryError)
+
def validate_applicable_for_selling_or_buying(self):
if not self.selling and not self.buying:
throw(_("Atleast one of the Selling or Buying must be selected"))
diff --git a/erpnext/public/js/controllers/transaction.js b/erpnext/public/js/controllers/transaction.js
index 1be4f27..6db849a 100644
--- a/erpnext/public/js/controllers/transaction.js
+++ b/erpnext/public/js/controllers/transaction.js
@@ -500,6 +500,9 @@
() => {
var d = locals[cdt][cdn];
me.add_taxes_from_item_tax_template(d.item_tax_rate);
+ if (d.free_item_data) {
+ me.apply_product_discount(d.free_item_data);
+ }
},
() => me.frm.script_manager.trigger("price_list_rate", cdt, cdn),
() => me.toggle_conversion_factor(item),