From d458e25dc5ae763a440d8ed039cf2c81643c0118 Mon Sep 17 00:00:00 2001 From: Rohit Waghchaure Date: Wed, 11 Dec 2019 21:55:28 +0530 Subject: [PATCH] fix: pricing rule working on non pricing rule items --- erpnext/accounts/doctype/pricing_rule/pricing_rule.py | 1 + erpnext/accounts/doctype/pricing_rule/utils.py | 3 ++- erpnext/public/js/controllers/transaction.js | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/erpnext/accounts/doctype/pricing_rule/pricing_rule.py b/erpnext/accounts/doctype/pricing_rule/pricing_rule.py index 17762755f42..efa7b5f1000 100644 --- a/erpnext/accounts/doctype/pricing_rule/pricing_rule.py +++ b/erpnext/accounts/doctype/pricing_rule/pricing_rule.py @@ -247,6 +247,7 @@ def get_pricing_rule_for_item(args, price_list_rate=0, doc=None): rules.append(get_pricing_rule_details(args, pricing_rule)) if pricing_rule.mixed_conditions or pricing_rule.apply_rule_on_other: + item_details.apply_rule_on_other_items = 1 continue if pricing_rule.coupon_code_based==1 and args.coupon_code==None: diff --git a/erpnext/accounts/doctype/pricing_rule/utils.py b/erpnext/accounts/doctype/pricing_rule/utils.py index ef26c2e7bfd..a9ef29598f0 100644 --- a/erpnext/accounts/doctype/pricing_rule/utils.py +++ b/erpnext/accounts/doctype/pricing_rule/utils.py @@ -410,7 +410,8 @@ def validate_pricing_rule_on_items(doc, item_row, do_not_validate = False): for pricing_rule in get_applied_pricing_rules(doc, item_row): pr_doc = frappe.get_doc('Pricing Rule', pricing_rule) - if pr_doc.get('apply_on') == 'Transaction': continue + if (pr_doc.get('apply_on') == 'Transaction' + or not pr_doc.get("mixed_conditions")): continue if pr_doc.get('price_or_product_discount') == 'Product': apply_pricing_rule_for_free_items(doc, pr_doc) diff --git a/erpnext/public/js/controllers/transaction.js b/erpnext/public/js/controllers/transaction.js index ca492baf5ab..d26c1f8d532 100644 --- a/erpnext/public/js/controllers/transaction.js +++ b/erpnext/public/js/controllers/transaction.js @@ -1352,7 +1352,7 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({ let me = this; const fields = ["discount_percentage", "discount_amount", "pricing_rules"]; - if (item.pricing_rules) { + if (item.pricing_rules && item.apply_rule_on_other_items) { frappe.call({ method: "erpnext.accounts.doctype.pricing_rule.utils.validate_pricing_rule_for_different_cond", args: {