mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-06 21:59:13 +00:00
Merge pull request #22328 from pipech/v12-hotfix-get_pricing_rule
fix(pricing_rules): pricing rule selector is wrong
This commit is contained in:
@@ -31,13 +31,19 @@ apply_on_table = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
def get_pricing_rules(args, doc=None):
|
def get_pricing_rules(args, doc=None):
|
||||||
pricing_rules = []
|
pricing_rules_all = []
|
||||||
values = {}
|
values = {}
|
||||||
|
|
||||||
for apply_on in ['Item Code', 'Item Group', 'Brand']:
|
for apply_on in ['Item Code', 'Item Group', 'Brand']:
|
||||||
pricing_rules.extend(_get_pricing_rules(apply_on, args, values))
|
pricing_rules_all.extend(_get_pricing_rules(apply_on, args, values))
|
||||||
if pricing_rules and not apply_multiple_pricing_rules(pricing_rules):
|
|
||||||
break
|
# removing duplicate pricing rule
|
||||||
|
pricing_rules_name = []
|
||||||
|
pricing_rules = []
|
||||||
|
for p in pricing_rules_all:
|
||||||
|
if p['name'] not in pricing_rules_name:
|
||||||
|
pricing_rules_name.append(p['name'])
|
||||||
|
pricing_rules.append(p)
|
||||||
|
|
||||||
rules = []
|
rules = []
|
||||||
|
|
||||||
@@ -323,9 +329,10 @@ def apply_internal_priority(pricing_rules, field_set, args):
|
|||||||
filtered_rules = []
|
filtered_rules = []
|
||||||
for field in field_set:
|
for field in field_set:
|
||||||
if args.get(field):
|
if args.get(field):
|
||||||
# filter function always returns a filter object even if empty
|
for rule in pricing_rules:
|
||||||
# list conversion is necessary to check for an empty result
|
if rule.get(field) == args.get(field):
|
||||||
filtered_rules = list(filter(lambda x: x.get(field)==args.get(field), pricing_rules))
|
filtered_rules = [rule]
|
||||||
|
break
|
||||||
if filtered_rules: break
|
if filtered_rules: break
|
||||||
|
|
||||||
return filtered_rules or pricing_rules
|
return filtered_rules or pricing_rules
|
||||||
|
|||||||
Reference in New Issue
Block a user