fix: Pricing Rule breaks if no item_code (#22653)

This commit is contained in:
Marica
2020-07-10 22:51:32 +05:30
committed by GitHub
parent b856548d47
commit 1696a8982c

View File

@@ -322,7 +322,9 @@ def apply_internal_priority(pricing_rules, field_set, args):
filtered_rules = []
for field in field_set:
if args.get(field):
filtered_rules = filter(lambda x: x[field]==args[field], pricing_rules)
# 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))
if filtered_rules: break
return filtered_rules or pricing_rules