From 66806ff1b067e9f0dee38456f3e33f777ad7f078 Mon Sep 17 00:00:00 2001 From: Poranut Chollavorn Date: Thu, 18 Jun 2020 13:43:15 +0000 Subject: [PATCH] fix(pricing_rules): rule won't got use across [item_code, item_group, brands] --- erpnext/accounts/doctype/pricing_rule/utils.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/erpnext/accounts/doctype/pricing_rule/utils.py b/erpnext/accounts/doctype/pricing_rule/utils.py index 9876246c47b..fa43e70c2d5 100644 --- a/erpnext/accounts/doctype/pricing_rule/utils.py +++ b/erpnext/accounts/doctype/pricing_rule/utils.py @@ -30,13 +30,19 @@ apply_on_table = { } def get_pricing_rules(args, doc=None): - pricing_rules = [] - values = {} + pricing_rules_all = [] + values = {} for apply_on in ['Item Code', 'Item Group', 'Brand']: - pricing_rules.extend(_get_pricing_rules(apply_on, args, values)) - if pricing_rules and not apply_multiple_pricing_rules(pricing_rules): - break + pricing_rules_all.extend(_get_pricing_rules(apply_on, args, values)) + + # removing duplicate pricing rule + pricing_rules_title = [] + pricing_rules = [] + for p in pricing_rules_all: + if p['title'] not in pricing_rules_title: + pricing_rules_title.append(p['title']) + pricing_rules.append(p) rules = []