mirror of
https://github.com/frappe/erpnext.git
synced 2026-03-11 06:17:44 +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):
|
||||
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_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 = []
|
||||
|
||||
@@ -323,9 +329,10 @@ def apply_internal_priority(pricing_rules, field_set, args):
|
||||
filtered_rules = []
|
||||
for field in field_set:
|
||||
if args.get(field):
|
||||
# filter function always returns a filter object even if empty
|
||||
# list conversion is necessary to check for an empty result
|
||||
filtered_rules = list(filter(lambda x: x.get(field)==args.get(field), pricing_rules))
|
||||
for rule in pricing_rules:
|
||||
if rule.get(field) == args.get(field):
|
||||
filtered_rules = [rule]
|
||||
break
|
||||
if filtered_rules: break
|
||||
|
||||
return filtered_rules or pricing_rules
|
||||
|
||||
Reference in New Issue
Block a user